[Python-Dev] Speeding up CPython 5-10%

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Feb 1 18:27:26 EST 2016


Sven R. Kunze wrote:
> Are there some resources on why register machines are considered faster 
> than stack machines?

If a register VM is faster, it's probably because each register
instruction does the work of about 2-3 stack instructions,
meaning less trips around the eval loop, so less unpredictable
branches and less pipeline flushes.

This assumes that bytecode dispatching is a substantial fraction
of the time taken to execute each instruction. For something
like cpython, where the operations carried out by the bytecodes
involve a substantial amount of work, this may not be true.

It also assumes the VM is executing the bytecodes directly. If
there is a JIT involved, it all gets translated into something
else anyway, and then it's more a matter of whether you find
it easier to design the JIT to deal with stack or register code.

-- 
Greg


More information about the Python-Dev mailing list