[Python-ideas] caching properties

Antoine Pitrou solipsis at pitrou.net
Thu Apr 30 13:06:25 CEST 2009


Steven D'Aprano <steve at ...> writes:
> 
> -1 on an extra parameter to property.
> 
> +1 on a cache decorator.

+1 for calling it "cached" or "memoize". I don't know if it has its place in the
builtin namespace, though. Putting it in functools would be fine.

(it may need a way to flush/invalidate the cache, too:

@cached
def foo(l=[4]):
    l[0] += 1
    return 4

print foo() # 5
print foo() # 5
foo.flush()
print foo() # 6

)





More information about the Python-ideas mailing list