[C++-sig] Functions exposed using boost::python not reported by the python profiler

Stefan Seefeld stefan at seefeld.name
Wed Aug 10 02:29:17 CEST 2011


On 08/09/2011 08:23 PM, Jim Bosch wrote:
> On 08/09/2011 03:57 PM, Arnaud Espanel wrote:
>> Hi --
>> When running a python program through the python profiler, calls to a
>> function exposed directly through C python api are reported, but not
>> the calls to a function exposed through boost::python. I'd like to see
>> boost::python calls reported on their own as well... but have not
>> managed to.
>
> This is my first look into how Python profiling works, but I think the
> basic problem is that Boost.Python-wrapped functions are really just
> callable objects.  Their implementation doesn't use the standard
> Python C-API procedure for exposing functions (which requires lots of
> static variables), and they of course aren't pure Python functions
> either.  So none of the triggers for trace events within Python itself
> every get called.
>
> The solution to is probably to modify the internals of Boost.Python's
> special Function type to explicitly trigger those events.  That's
> probably what the behavior of Boost.Python should be, and I suspect it
> would be a fairly small change to make.
>
> It's worrying that the functions that trigger the events don't appear
> to be a documented part of the Python C-API, though.  The only way to
> figure out how to do it would be to dive into the Python code itself,
> and hope those functions are stable between Python releases.

I would actually go one step further and report this issue (of
undocumented / non-public functions required for tracing) to the Python
bug tracker (http://bugs.python.org), and hope that this gets properly
addressed.

    Stefan

-- 

      ...ich hab' noch einen Koffer in Berlin...



More information about the Cplusplus-sig mailing list