[Python-Dev] Why is Bytecode the way it is? (original) (raw)
Guido van Rossum guido at python.org
Thu Jul 15 03:47:29 CEST 2004
- Previous message: [Python-Dev] Why is Bytecode the way it is?
- Next message: [Python-Dev] Why is Bytecode the way it is?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
While recently goofing around with the bytecode, I thought of doing something like this:
case LOADCONST: x = GETITEM(consts, oparg); PyINCREF(x); + if (*nextinstr == RETURNVAL) { + retval = x; + why = WHYRETURN; + goto fastblockend; + } PUSH(x); goto fastnextopcode; This would skip the stack and a trip through the loop without changing the parser or the bytecode, and with a minimal amount of added code or overhead. This could (of course) be applied to other opcodes, too.
At the cost of an extra pointer dereference and jump, and usually for naught (the uses of LOAD_CONST not in a return statement must certainly vastly outnumber those in return statements).
Have you timed this? I doubt you can measure a consistent performance increase across platforms.
--Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] Why is Bytecode the way it is?
- Next message: [Python-Dev] Why is Bytecode the way it is?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]