Q: Python 2.0 preliminary features?

skaller skaller at maxtal.com.au
Sun Oct 10 22:16:15 EDT 1999


Preston Landers wrote:

> And just because I like to start flame wars, I'll go ahead and add my
> own feature to the wishlist:  nested scopes / namespaces.  Is this a
> pipe dream

This is already implemented in Viperi. Works fine: there are
no problems with representation because it is using a functional
programming language with a garbage collector as the implementation
language. However, I do not use chained stack frames, and I do not
use Python's 'two scope with builtins hack' model; instead,
there is a single abstraction called an environment in which
lookup is done; the implementation uses a list of dictionaries,
amoung other things, to represent the 'display' (list of activation
records). [The 'globals' scope is near the bottom, builtins is at the
bottom]

In the second stage, fast loading is supported, using an indexed
array instead of a dictionary: CPython does this for functions,
whereas Viper does it for both nested functions and modules as well.
[I'm currently implementing this]. Inlining naturally fits into
this stage, in the first instance.

In the third stage, type inference will attempt to ascribe types to
the variables, and use some fixed ad hoc speedups to improve
interpreter speed even further.

Finally, the fourth stage converts client functions to built-in
functions, that is, compiled code (probably, machine code);
and binds the program down to an binary executable.

[It isn't clear yet whether to generate for the CPython object
model or not, but this has advantages such as performance
and compatibility that are hard to overlook, but will make
extensions like nested functions harder to support]

-- 
John Skaller, mailto:skaller at maxtal.com.au
1/10 Toxteth Rd Glebe NSW 2037 Australia
homepage: http://www.maxtal.com.au/~skaller
downloads: http://www.triode.net.au/~skaller




More information about the Python-list mailing list