Python functools.html() Examples

The following are 1 code examples for showing how to use functools.html(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the exmaples you don't like. You can also save this page to your account.

Example 1
Project: pyro   Author: uber   File:    (license) View Source Project 5 votes vote down vote up
def memoize(fn):
    unbounded memoize
    alternate in py3:
    mem = {}

    def _fn(*args, **kwargs):
        kwargs_tuple = _dict_to_tuple(kwargs)
        if (args, kwargs_tuple) not in mem:
            mem[(args, kwargs_tuple)] = fn(*args, **kwargs)
        return mem[(args, kwargs_tuple)]
    return _fn