FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-148871: make `LOAD_COMMON_CONSTANT` use immortal stackref borrows by NekoAsakura · Pull Request #149625 · python/cpython · GitHub

/ cpython Public

gh-148871: make LOAD_COMMON_CONSTANT use immortal stackref borrows - #149625

Merged
markshannon merged 6 commits into
python:mainfrom
NekoAsakura:gh-148871-immortal-stackref
May 28, 2026
Merged

gh-148871: make LOAD_COMMON_CONSTANT use immortal stackref borrows#149625
markshannon merged 6 commits into
python:mainfrom
NekoAsakura:gh-148871-immortal-stackref

Conversation

NekoAsakura commented May 9, 2026
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

gc.is_tracked(all/any) True -> False

Comment thread Python/bytecodes.c Outdated
// Keep in sync with _common_constants in opcode.py
assert(oparg < NUM_COMMON_CONSTANTS);
value = PyStackRef_FromPyObjectNew(tstate->interp->common_consts[oparg]);
value = PyStackRef_DUP(tstate->interp->common_consts[oparg]);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This needs to check the tag.

Could you add PyStackRef_DupImmortal(ref) which would return its argument unchanged and assert that the referenced object is immortal, otherwise it defeats the point of changing PyObject * to _PyStackRef here

Comment thread Python/flowgraph.c Outdated
if (opcode == LOAD_COMMON_CONSTANT) {
assert(oparg < NUM_COMMON_CONSTANTS);
return Py_NewRef(_PyInterpreterState_GET()->common_consts[oparg]);
return Py_NewRef(PyStackRef_AsPyObjectBorrow(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
return Py_NewRef(PyStackRef_AsPyObjectBorrow(
return PyStackRef_AsPyObjectBorrow(

These objects are immortal, you can borrow references to them.

Copy link
Copy Markdown
Member Author

Thanks for reviewing :')
Unfortunately I cannot get on my remote server right now due to some network issues, but I’ll sort the requested changes tomorrow.

markshannon self-requested a review May 28, 2026 10:16

markshannon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks good. Thanks for doing this

markshannon merged commit 39bd44f into python:main May 28, 2026
105 of 106 checks passed
NekoAsakura deleted the gh-148871-immortal-stackref branch May 28, 2026 23:25
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL