Vladimir Marangozov wrote: ...
I wrote a very rough first implementation of this idea. The files are at:
http://sirac.inrialpes.fr/~marangoz/python/lineno/
Basically, what I did is:
1) what I said :-) 2) No more SET_LINENO 3) In tracing mode, a copy of the original code is put in an additional slot (co_tracecode) of the code object. Then it's overwritten with CALL_TRACE opcodes at the locations returned by PyCode_Line2Addr.
I'd rather keep the original code object as it is, create a copy with inserted breakpoints and put that into the frame slot. Pointing back to the original from there. Then I'd redirect the code from the CALL_TRACE opcode completely to a user-defined function. Getting rid of the extra code object would be done by this function when tracing is off. It also vanishes automatically when the frame is released.
a) how to deallocate the modified code string when tracing is off
By making the copy a frame property which is temporary, I think. Or, if tracing should work for all frames, by pushing the original in the back of the modified. Both works. ciao - chris -- Christian Tismer :^) <mailto:tismer@appliedbiometrics.com> Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home