[Python-Dev] Fast access to __builtins__
Thu, 27 Mar 2003 19:35:20 -0500
> The behavior of a program under -O should be as similar as possible to normal
> operation. This would break that for some programs.
> A per-file pragma directive would work.
> This is clearly a semantic change, so
> I'd like to see a different command line flag control this behavior
> Using the -O for this is not a working possibility. -OO
> is reserved for optimizations which can change semantics,
> but even there, I'd rather like a per-module switch than
> a command line switch.
That makes good sense.
Are you guys thinking of something like this:
__fastbuiltins__ = True # optimize all subsequent defs in the module
> The downside of a pragma module or
> keyword would be what people try to add to it later.
Ideally, enabling the pragma would also trigger warnings when the
module shadows a builtin.
> BTW, why not have a new opcode for symbols in the
> builtins and then only tweak the opcode implementation
> instead of having the compiler generate different code ?
Either way results in changing one opcode/oparg pair, so I
don't see how having a new opcode helps. At some point,
the name has to be looked-up and a reference to it stored.
Afterwards, LOAD_CONST is all that is needed to fetch