[Python-Dev] Christmas Wishlist

Phillip J. Eby pje at telecommunity.com
Mon Dec 15 14:32:27 EST 2003

At 02:26 PM 12/15/03 -0500, Raymond Hettinger wrote:
> > On Sun, Dec 14, 2003 at 04:31:09PM -0500, Raymond Hettinger wrote:
> > > I. eval() to accept custom mapping arguments for globals and locals.
> > > This makes it possible to write a smart __getitem__ method for
> > > applications like spreadsheets or case-insensitive evaluation.
> >
> > http://mail.python.org/pipermail/python-dev/2002-October/029770.html
> > [and the rest of that thread]
>[Jeff Epler]
> > A 3% slowdown in the common case was considered too big to allow a
> > feature like this to be included.  The slowdown might be smaller if
> > the builtin module wasn't allowed to be anything but a dict instance,
> > might disappear if there were two versions of ceval.c were included,
> > one used PyObject_ APIs and the other used PyDict_ APIs (as long as
> > one was fighting for space in the cpu cache, main memory, etc)
>Ordinarily, I would say that 3% is a reasonable price to pay for this
>functionality but there is that pesky pie throwing event coming up.

There is a workaround for this in CPython, which used to be used by Zope, 
and which I have used on occasion: scan the code object for LOAD_NAME 
opcodes, and note what names are used by the code block.  Then, look up 
those names in your non-dictionary dictionary, and copy them into a real 

So, it's got to be something pretty specialized to really need PyObject_* 
APIs instead of PyDict_* APIs in CPython at present.  Why penalize 
*everything* for such an specialized need?

More information about the Python-Dev mailing list