Revert "bpo-40521: Remove freelist from collections.deque() (GH-21073)" by rhettinger · Pull Request #24944 · python/cpython
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be re-applied if the subinterpreters PEP is approved.
subinterpreters exist for years and are used by multiple projects. The recent work is to make more code compatible with subinterpreters (make the code "correct"), only a small part of the work is really specific to preparing CPython code base for running multiple interpreters in parallel.
|
|
||
| #define MAXFREEBLOCKS 16 | ||
| static Py_ssize_t numfreeblocks = 0; | ||
| static block *freeblocks[MAXFREEBLOCKS]; |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you define the freelist in PyInterpreterState to make it per-interpreter, and so compatible with subinterpreters?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The subinterpreters PEP is not approved a likely won't be for Python 3.10, so I don't want to pay that cost now. These macros are used heavily throughout the rest of the module and are performance sensitive. For Python 3.11 and later, this can be reapplied. Even then, it would probably be better to remove the freelists entirely than to add fenced logic to get the current interpreter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters