Skip to content

Python wrappers are not profiled separately when binding=True #2137

Description

@mhsmith

Cython 0.27.3, Python 3.6.3.

#cython: binding=True, profile=True

cpdef f(x):
    if x > 0:
        f(x - 1)
>>> cProfile.run("for i in range(5): proftest.f(2)")
         23 function calls (8 primitive calls) in 0.000 seconds

   Ordered by: standard name

       ncalls  tottime  percall  cumtime  percall filename:lineno(function)
            1    0.000    0.000    0.000    0.000 <string>:1(<module>)
         20/5    0.000    0.000    0.000    0.000 proftest.pyx:3(f)
            1    0.000    0.000    0.000    0.000 {built-in method builtins.exec}
            1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

By comparison, with binding=False (the default):

>>> cProfile.run("for i in range(5): proftest.f(2)")
         28 function calls (18 primitive calls) in 0.000 seconds

   Ordered by: standard name

       ncalls  tottime  percall  cumtime  percall filename:lineno(function)
            1    0.000    0.000    0.000    0.000 <string>:1(<module>)
            5    0.000    0.000    0.000    0.000 proftest.pyx:3(f (wrapper))
         15/5    0.000    0.000    0.000    0.000 proftest.pyx:3(f)
            1    0.000    0.000    0.000    0.000 {built-in method builtins.exec}
            5    0.000    0.000    0.000    0.000 {built-in method proftest.f}
            1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions