This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author methane
Recipients methane, xiang.zhang
Date 2017-03-06.17:06:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1488820008.54.0.550818812632.issue29676@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-03-06 17:06:48methanesetrecipients: + methane, xiang.zhang
2017-03-06 17:06:48methanesetmessageid: <1488820008.54.0.550818812632.issue29676@psf.upfronthosting.co.za>
2017-03-06 17:06:48methanelinkissue29676 messages
2017-03-06 17:06:48methanecreate