[Python-ideas] Python execution progress counter
Robert Kern
robert.kern at gmail.com
Sun Jun 23 22:25:39 CEST 2013
On 2013-06-23 17:49, anatoly techtonik wrote:
> In x86 assembly there is a concept of instruction pointer (IP) that indicates
> where a computer is in its program sequence (c)
> http://en.wikipedia.org/wiki/Program_counter
>
> I wonder if it is possible to implement a similar thing in Python? Not the
> instruction pointer, which points to the linear memory address space (and
> therefore is a 1D structure), but a 2D Execution Progress Counter, which counts
> position in program sequence for every stack level?
The `f_lasti` attribute of frame objects records the index of the last bytecode
instruction that was executed in that frame.
http://docs.python.org/3/reference/datamodel.html#frame-objects
This is, of course, an implementation detail of CPython.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-ideas
mailing list