What does Python fix?

Alex Martelli aleax at aleax.it
Sun Jan 20 22:26:41 CET 2002

François Pinard wrote:
> time to study the PEP (or Python documentation if any) on nested scopes:
> it might be especially worth if the magically implement usable closures.

They do, as long as the closures would also be usable in (e.g.) ML or
Haskell -- because there's no decent way to re-bind free variables (in
typical FP languages, you never re-bind anything, yet their closures are
usual and frequently used, so...:-).

> All such things, in fact.  If the focus list becomes big, it might imply
> some extra-time for copying, and some memory for keeping extra-copies.
> In Lisp, there is the capability of having genuine pointers all along a
> single list.  There is probably no memory-efficient equivalent in Python.

I don't know what "genuine pointers" are in this context (as opposed to
Python references).  Do you mean pointers subject to address-arithmetic,
as in C?  In any case, if for some given application you think cons cells 
are the way to go, they're easy to make in Python.  I've chosen them as
an extension example, but they really work well in pure Python too.  See
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66509 ...


More information about the Python-list mailing list