cython/cython

Python wrappers are not profiled separately when binding=True

Open

#2,137 建立於 2018年3月10日

在 GitHub 查看
 (3 留言) (0 反應) (0 負責人)Python (8,663 star) (1,517 fork)batch import
Code Generationdefectgood first issuehelp wanted

描述

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}

貢獻者指南