GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-131238: Move _Py_VISIT_STACKREF() to pycore_stackref.h by vstinner · Pull Request #131560 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Mar 21, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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.
  • Issue: Our internal headers are far too interlinked #131238

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner vstinner added the skip news label Mar 21, 2025
@vstinner
vstinner requested review from Fidget-Spinner and markshannon as code owners March 21, 2025 17:44
@bedevere-app bedevere-app Bot added the awaiting core review label Mar 21, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Mar 21, 2025
Our internal headers are far too interlinked #131238
Closed
@vstinner
pythongh-131238: Move _Py_VISIT_STACKREF() to pycore_stackref.h
22b8497
* 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
vstinner force-pushed the visit_stackref branch from b1acd0a to 22b8497 Compare March 21, 2025 17:45
@vstinner
vstinner requested review from a team and erlend-aasland as code owners March 21, 2025 17:45
colesbury
colesbury reviewed Mar 21, 2025
View reviewed changes
Comment thread Include/internal/pycore_stackref.h
#define _Py_VISIT_STACKREF(ref) \
do { \
if (!PyStackRef_IsNull(ref)) { \
int vret = _PyGC_VisitStackRef(&(ref), visit, arg); \

@colesbury colesbury Mar 21, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This depends on _PyGC_VisitStackRef, which is in pycore_gc.h.

What's the motivation for moving the macro here?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vstinner vstinner Mar 21, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vstinner vstinner Mar 21, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner
vstinner merged commit 7101cba into python:main Mar 21, 2025
@vstinner
vstinner deleted the visit_stackref branch March 21, 2025 22:24
@bedevere-app bedevere-app Bot removed the awaiting core review label Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@colesbury colesbury colesbury left review comments
@Fidget-Spinner Fidget-Spinner Awaiting requested review from Fidget-Spinner Fidget-Spinner is a code owner
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner
@erlend-aasland erlend-aasland Awaiting requested review from erlend-aasland erlend-aasland is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@vstinner @colesbury
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.