Message289121
OK, now I found what caused this difference.
lsprof expect `func` is PyCFunction object. But it can be PyMethodDescrObject when LOAD_METHOD is used to call C method.
In Modules/_lsprof.c (line 459):
case PyTrace_C_CALL:
if ((((ProfilerObject *)self)->flags & POF_BUILTINS)
&& PyCFunction_Check(arg)) {
ptrace_enter_call(self,
((PyCFunctionObject *)arg)->m_ml,
arg);
}
Document says just it's "Function object being called."
https://docs.python.org/3.6/c-api/init.html#c.Py_tracefunc
If "function object" means "any C object having tp_call", most easy way to solve this issue is adding PyMethodDescrObject support to lsprof.
PyEval_GetFuncName() and PyEval_GetFuncDesc() should support it too.
As a bonus, `list.append(L, x)` will be profiled like `L.append(x)`. It looks more consistent.
On the other hand, if it means it's PyCFunction, we can't call PyMethodDescrObject directly.
Since PyEval_SetProfile() is old function, I chose later way for now. |
|
Date |
User |
Action |
Args |
2017-03-06 17:06:48 | methane | set | recipients:
+ methane, xiang.zhang |
2017-03-06 17:06:48 | methane | set | messageid: <1488820008.54.0.550818812632.issue29676@psf.upfronthosting.co.za> |
2017-03-06 17:06:48 | methane | link | issue29676 messages |
2017-03-06 17:06:48 | methane | create | |
|