Building CPython

Gregory Ewing greg.ewing at canterbury.ac.nz
Fri May 15 20:55:51 EDT 2015


BartC wrote:
> For example, there is a /specific/ byte-code called BINARY_ADD, which 
> then proceeds to call a /generic/ binary-op handler! This throws away 
> the advantage of knowing at byte-code generation time exactly which 
> operation is needed.

While inlining the binary-op handling might give you a
slightly shorter code path, it wouldn't necessarily speed
anything up. It's possible, for example, that the shared
binary-op handler fits in the instruction cache, but the
various inlined copies of it don't, leading to a slowdown.

The only way to be sure about things like that is to try
them and measure. The days when you could predict the speed
of a program just by counting the number of instructions
executed are long gone.

-- 
Greg



More information about the Python-list mailing list