[Python-Dev] Making builtins more efficient

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Mar 10 00:46:49 CET 2006


Steven Elliott wrote:
> One way of handling it is to
> alter STORE_ATTR (op code for assigning to mod.str) to always check to
> see if the key being assigned is one of the default builtins.  If it is,
> then the module's indexed array of builtins is assigned to.

As long as you're going to all that trouble, it
doesn't seem like it would be much harder to treat
all global names that way, instead of just a predefined
set. The compiler already knows all of the names that
are used as globals in the module's code.

> That's great, but I'm curious if additional gains can be
> made be focusing just on builtins.

As long as builtins can be shadowed, I can't see how
to make any extra use of the fact that it's a builtin.
A semantic change would be needed, such as forbidding
shadowing of builtins, or at least forbidding this
from outside the module.

Greg



More information about the Python-Dev mailing list