[Python-Dev] Possible optimization for LOAD_FAST ?
fijall at gmail.com
Wed Jan 5 14:27:31 CET 2011
How about not changing semantics and still making this optimization possible?
PyPy already has CALL_LIKELY_BUILTIN which checks whether builtins has
been altered (by keeping a flag on the module dictionary) and if not,
loads a specific builtin on top of value stack. From my current
experience, I would make a bet that someone is altering pretty much
every builtin for some dark reasons. One that comes to mind is to test
something using external library which is not playing along too well.
That however only lets one avoid dictionary lookups, it doesn't give
potential for other optimizations (which in my opinion are limited
until we hit something dynamic like an instance, but let's ignore it).
How about creating two copies of bytecode (that's not arbitrary
number, just 2) and a way to go from more optimized to less optimized
in case *any* of promises is invalidated? That gives an ability to
save semantics, while allowing optimizations.
That said, I think CPython should stay as a simple VM and refrain from
doing things that are much easier in the presence of a JIT (and give a
lot more speedups), but who am I to judge.
More information about the Python-Dev