Stefan Behnel added the comment:

This is not purely about speeding up the code. It's also about avoiding to 
replace the code object of a function, which is essentially a big and clumsy 
hack only to achieve setting a flag. Some tools, namely line_profiler, use the 
current code object as a dict key for state keeping. Replacing the reference in 
"__code__" might confuse them if they happened to catch a reference before.

That's why I asked for applying at least the simple patch that sets the flag 
with a C level helper function. But I'd be ok with applying the latest patch as 
it is. The non-flag-setting parts are simple and a straight forward translation 
of the current Python code.


Python tracker <>
Python-bugs-list mailing list

Reply via email to