[Python-Dev] Fast access to __builtins__

Guido van Rossum guido@python.org
Fri, 28 Mar 2003 07:33:19 -0500


> Does it check if it's one of the standard __builtin__ module or
> whether it is an attribute of whatever object is currently set as
> the module's __builtins__ attribute?

Only standard builtins need to be exempt, because the compiler isn't
going to optimize non-standard builtins.  That's because (a) there
won't be special opcodes that implement those builtins directly, and
(b) the bytecode compiler doesn't know the contents of __builtins__ so
it can't possibly know about nonstandard builtins anyway to generate a
LOAD_BUILTIN opcode.

BTW, I expect that nonstandard builtins will be ruled out in some
future version of the language, or will have to be declared
differently.  They are too confusing for the human reader of the code.

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