• Jeremy Hylton's avatar
    Small function call optimization and special build option for call stats. · 985eba53
    Jeremy Hylton yazdı
    -DCALL_PROFILE: Count the number of function calls executed.
    
    When this symbol is defined, the ceval mainloop and helper functions
    count the number of function calls made.  It keeps detailed statistics
    about what kind of object was called and whether the call hit any of
    the special fast paths in the code.
    
    Optimization:
    
    When we take the fast_function() path, which seems to be taken for
    most function calls, and there is minimal frame setup to do, avoid
    call PyEval_EvalCodeEx().  The eval code ex function does a lot of
    work to handle keywords args and star args, free variables,
    generators, etc.  The inlined version simply allocates the frame and
    copies the arguments values into the frame.
    
    The optimization gets a little help from compile.c which adds a
    CO_NOFREE flag to code objects that don't have free variables or cell
    variables.  This change allows fast_function() to get into the fast
    path with fewer tests.
    
    I measure a couple of percent speedup in pystone with this change, but
    there's surely more that can be done.
    985eba53
compile.h 3.31 KB