Why doesn't JUMP_IF_FALSE do POP_TOP ?

Skip Montanaro skip at pobox.com
Mon Jan 13 18:15:50 CET 2003

    Bengt> I.e., it should be simple to instrument ceval.c to extern link to
    Bengt> a temp module with an integer array indexed by byte code value to
    Bengt> increment for statistics.  

You can already do this.  Simply define DYNAMIC_EXECUTION_PROFILES (and
optionally DXPAIRS) when building Python.  I believe only ceval.c and
sysmodule.c need to be rebuilt.  Once built, you can call sys.getdxp() at
any time during program execution to retrieve the byte code execution
frequency array.  If you define DXPAIRS as well as
DYNAMIC_EXECUTION_PROFILES you get a 2-D list (list of lists) instead of a
simple list identifying adjoining pairs of byte code instructions.  This is
probably what you want for this task, as it will tell you how often a
conditional jump is followed by a POP_TOP, not just how many POP_TOP
instructions are executed.


More information about the Python-list mailing list