4 ms·
Does it actually reference the parent, or does it just make a copy? One is a closure, the other is an implementation artifact.
by KirinDave 16y ago
Does it actually reference the parent, or does it just make a copy? One is a closure, the other is an implementation artifact.
- rlpb 16y agoFrom a quick test, it appears that it can reference everything the parent can reference and does not make a copy.
- gxti 16y agoIt doesn't make a copy. It creates a special object (which you don't see unless you're digging in the internals) called a "cell" which holds a reference to the object for as long as the function exists. To see for yourself, look at `somefunc.func_closure` -- it'll be `None` on regular functions, and a tuple of cells on a closure function.