castironpi wrote:
On Jul 17, 5:37 pm, I V <[EMAIL PROTECTED]> wrote:


Oh.  How is the stack represented?

As usual, as successive locations in memory.
I have the impression that CPython uses the same stack C does.
While conceptually, CPython may put objects on the stack, I am pretty sure it actually stacks references (C pointers) to objects in heap memory.

> Does it keep track of which stack
positions (TOS, TOS1, etc.) are in what registers?

I am sure they are not in registers, just normal memory.
The C code that implements bytecodes to act on stack values will use registers just like any other C code. So using registers for the stack would get in the way. Of course, the C code might load pointers on the stack into address registers when actually needed. But this depends on the address scheme of a particular processor and how the C code is compiled to its object code.

Does stack manipulation consume processor cycles?

Of course.  For much more, you should peruse the CPython source.

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to