badchars.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:expdevBadChars 作者: mgeeky 项目源码 文件源码
def memoized(func):
    ''' A function decorator to make a function cache it's return values.
    If a function returns a generator, it's transformed into a list and
    cached that way. '''
    cache = {}
    def wrapper(*args):
        if args in cache:
            return cache[args]
        val = func(*args)
        if isinstance(val, types.GeneratorType):
            val = list(val)
        cache[args] = val
        return val
    wrapper.__doc__ = func.__doc__
    wrapper.func_name = '%s_memoized' % func.func_name
    return wrapper
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号