Function decorator that caches function results

Fredrik Lundh fredrik at
Sun Oct 9 18:00:13 CEST 2005

Steven D'Aprano wrote:

> "Each def or lambda expression that is executed will create a closure if
> the body of the function or any contained function has free variables."
> Presumably that means that if there are no free variables, no closure
> is created.

you're quoting selectively; the word "closure" isn't used anywhere
in the design document except for a section that talks about "flat
closures", which is an implementation approach used in CPython
(as the sentence before the one you quoted explains).

I don't think it's necessarily a good idea to treat a reference to an
algorithm and an attribute on an object in a specific implementation
as the definition of an computer term...


More information about the Python-list mailing list