[Python-Dev] More flexible namespaces.

Guido van Rossum guido at CNRI.Reston.VA.US
Fri Apr 30 05:00:52 CEST 1999


> To cut a long story short, I would like eval and exec to be capable of
> working with arbitrary mapping objects rather than only dictionaries.  The
> general idea is that I can provide a class with mapping semantics, and pass
> this to exec/eval.

I agree that this would be seriously cool.  It will definitely be in
Python 2.0; it's already in JPython.

Quite a while ago, Ian Castleden sent me patches for 1.5.1 to do this.
It was a lot of code and I was indeed worried about slowing things
down too much (and also about checking that he got all the endcases
right).

Ian did benchmarks and found that the new code was consistently
slower, by 3-6%.  Perhaps for Python 1.6 this will be acceptable (the
"Python IS slow" thread notwithstanding :-); or perhaps someone can
have a look at it and squeeze some more time out of it?  I'll gladly
forward the patches.

--Guido van Rossum (home page: http://www.python.org/~guido/)




More information about the Python-Dev mailing list