[Python-Dev] setprofile and settrace inconsistency (original) (raw)
Alon Horev alon at horev.net
Fri Jun 1 17:22:42 CEST 2012
- Previous message: [Python-Dev] PEP 11 change: Windows Support Lifecycle
- Next message: [Python-Dev] setprofile and settrace inconsistency
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
When setting a trace function with settrace, the trace function when called with a new scope can return another trace function or None, indicating the inner scope should not be traced. I used settrace for some time but calling the trace function for every line of code is a performance killer. So I moved on to setprofile, which calls a trace function every function entry/exit. now here's the problem: the return value from the trace function is ignored (intentionally), denying the possibility to skip tracing of 'hot' or 'not interesting' code.
I would like to propose two alternatives:
- setprofile will not ignore the return value and mimic settrace's behavior.
- setprofile is just a wrapper around settrace that limits it's functionality, lets make settrace more flexible so setprofile will be redundant. here's how: settrace will recieve an argument called 'events', the trace function will fire only on events contained in that list. for example: setprofile = partial(settrace, events=['call', 'return'])
I personally prefer the second.
Some context to this issue: I'm building a python tracer - a logger that records each and every function call. In order for it to run in production systems, the overhead should be minimal. I would like to allow the user to say which function/module/classes to trace or skip, for example: the user will skip all math/cpu intensive operations. another example: the user will want to trace his django app code but not the django framework.
your thoughts?
Thanks, Alon Horev
-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20120601/db0be484/attachment-0001.html>
- Previous message: [Python-Dev] PEP 11 change: Windows Support Lifecycle
- Next message: [Python-Dev] setprofile and settrace inconsistency
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]