[Python-ideas] Optimizing builtins
Nick Coghlan
ncoghlan at gmail.com
Sat Jan 1 01:50:09 CET 2011
On Sat, Jan 1, 2011 at 4:49 AM, Guido van Rossum <guido at python.org> wrote:
> (FWIW, optimizing "x[i] = i" would be much simpler -- I don't really
> care about the argument that a debugger might interfere. But again,
> apart from the simplest cases, it requires a sophisticated parser to
> determine that it is really safe to do so.)
Back on topic, we've certainly made much bigger bytecode changes that
would appear differently in a debugger. Collapsing most of the with
statement entry overhead into the single SETUP_WITH opcode is the
biggest recent(-ish) example that comes to mind.
A more general peephole optimisation that picks up a repeated load
operation in a sequence of load commands and replaces it with a single
load and some stack rotations may be feasible, but I'm not entirely
sure that would actually be an optimisation (especially for LOAD_FAST)
- reordering the stack may be slower than the load operation.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list