[New-bugs-announce] [issue44590] Create frame objects lazily when needed

Mark Shannon report at bugs.python.org
Fri Jul 9 06:53:40 EDT 2021


New submission from Mark Shannon <mark at hotpy.org>:

In https://bugs.python.org/issue44032 we moved most of the data in the frame stack, that is the locals, stack, and "specials" (globals, builtins, code etc), from the heap allocated stack to a (mostly) contiguous array in memory.
That offered some speed up due to better cache locality, and faster allocation of frame objects (they are now fixed size so can use a simple freelist).

However, data is still split between the stack allocated frame and the heap allocated frame.

We should move the remaining data to the stack and only allocate heap objects lazily when needed for tracebacks and the like. This should improve performance further by removing the vast majority of heap frame allocations and further improving locality of reference.

Not only does this have immediate performance benefits, it also paves the way for even better Python-to-Python calls by allowing stack frames to overlap and pass arguments with the minimal amount of copying and INCREF/DECREF pairs.

----------
assignee: Mark.Shannon
components: Interpreter Core
messages: 397196
nosy: Mark.Shannon, gvanrossum, pablogsal
priority: normal
severity: normal
status: open
title: Create frame objects lazily when needed
type: performance
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44590>
_______________________________________


More information about the New-bugs-announce mailing list