ANN: Stackless Python 0.2

Tim Peters tim_one at
Tue Jun 29 03:15:15 EDT 1999

[Tim sez Python stores space for each code object's "Python stack" in a
 runtime frame object]

[Toby J Sargeant]
> This might be completely irrelevant, but during the course of my
> masters, I considered doing this kind of thing to java in order to
> allow asynchronous threads to share stack frames (don't ask...).

Don't tell <wink>.

> My supervisor complained bitterly on the grounds that function
> invocations where orders of magnitude more common than object creation,
> and hence associating memory allocation/deallocation with every call was
> considered horrendously inefficient.
> It seems that this should affect Stackless Python equally as
> much.

No more so than Stackful Python:  Python has always worked this way;
Stackless Python doesn't change this aspect.

> Does anyone have anything to add on the subject? I would imagine that
> frames could be allocated and managed in chunks to alleviate a lot of
> the memory management load...

The code is in Objects/frameobject.c, and easy to follow.  frameobjects are
recycled  via their own free list.  Typically the total number of
frame-associated mallocs is proportional to the maximum depth of the call
stack, not to the number of calls made.

Setting up a Python frame remains expensive, but for other reasons.

115-lines-of-code-doesn't-run-in-one-cycle-malloc-or-not<wink>-ly y'rs  -

More information about the Python-list mailing list