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

gh-131238: Move _Py_VISIT_STACKREF() to pycore_stackref.h by vstinner · Pull Request #131560 · python/cpython · GitHub

/ cpython Public

gh-131238: Move _Py_VISIT_STACKREF() to pycore_stackref.h - #131560

Merged
vstinner merged 1 commit into
python:mainfrom
vstinner:visit_stackref
Mar 21, 2025
Merged

gh-131238: Move _Py_VISIT_STACKREF() to pycore_stackref.h#131560
vstinner merged 1 commit into
python:mainfrom
vstinner:visit_stackref

Conversation

vstinner commented Mar 21, 2025
edited
Loading

Copy link
Copy Markdown
Member
  • Move _Py_VISIT_STACKREF() from pycore_gc.h to pycore_stackref.h.
  • Remove pycore_interpframe.h include from pycore_genobject.h.
  • Remove now useless includes from C files.
  • Add pycore_interpframe_structs.h to Makefile.pre.in and pythoncore.vcxproj.

* Move _Py_VISIT_STACKREF() from pycore_gc.h to pycore_stackref.h.
* Remove pycore_interpframe.h include from pycore_genobject.h.
* Remove now useless includes from C files.
* Add pycore_interpframe_structs.h to Makefile.pre.in and
  pythoncore.vcxproj.
vstinner requested review from a team and erlend-aasland as code owners March 21, 2025 17:45
#define _Py_VISIT_STACKREF(ref) \
do { \
if (!PyStackRef_IsNull(ref)) { \
int vret = _PyGC_VisitStackRef(&(ref), visit, arg); \

Copy link
Copy Markdown
Contributor

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 depends on _PyGC_VisitStackRef, which is in pycore_gc.h.

What's the motivation for moving the macro here?

Copy link
Copy Markdown
Member Author

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

pycore_stackref.h depends on pycore_object.h which depends on pycore_gc.h.

_Py_VISIT_STACKREF() (currently defined in pycore_gc.h) uses PyStackRef_IsNull() which is defined in pycore_stackref.h.

Problem: If dependencies are made explicit (that's part of my work), pycore_gc.h should depend on pycore_stackref.h which creates a dependency cycle!

Moving _Py_VISIT_STACKREF() to pycore_stackref.h breaks this cycle.

Copy link
Copy Markdown
Member Author

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

Previously, using _Py_VISIT_STACKREF() without including pycore_stackref.h worked thanks to luck and the fact that including one header pulled dozens of other headers. With my work on reducing dependencies, this luck is gone, and dependencies must be written explicitly.

vstinner merged commit 7101cba into python:main Mar 21, 2025
vstinner deleted the visit_stackref branch March 21, 2025 22:24
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