[Python-Dev] Why do we need Traceback Objects?

Guido van Rossum guido@python.org
Thu, 06 Apr 2000 21:25:35 -0400


> What happens is that in tracing mode, a copy of the original code stream
> is created, a new CALL_TRACE opcode is stored in it at the addresses
> corresponding to each source line number, then the instruction pointer
> is redirected to execute the modified code string. Whenever a CALL_TRACE
> opcode is reached, the callback is triggered. On a successful return, 
> the original opcode at the current address is fetched from the original
> code string, then directly goto the dispatch code.
> 
> This code string duplication & conditional break-point setting occurs
> only when a trace function is set; in the "normal case", the interpreter
> executes a code string without SET_LINENO.

Ai!  This really sounds like a hack.  It may be a standard trick in
the repertoire of virtual machine implementers, but it is still a
hack, and makes my heart cry.  I really wonder if it makes enough of
a difference to warrant all that code, and the risk that that code
isn't quite correct.  (Is it thread-safe?)

--Guido van Rossum (home page: http://www.python.org/~guido/)