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-84436: Add codemod for _PyVarObject_HEAD_IMMORTAL_INIT by eduardo-elizondo · Pull Request #103308 · python/cpython

Conversation

@eduardo-elizondo

@eduardo-elizondo eduardo-elizondo commented Apr 6, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

This extends the main PR19474 by running the codemod to replace all internal uses of PyVarObject_HEAD_INIT for _PyVarObject_HEAD_IMMORTAL_INIT to be able to initialize them as immortal instances.

The reason this was separated out was to provide a cleaner PR to review the main changes of immortal instances in PR19474. While this one is mostly the codemoded files. Created this as direct feedback from: #19474 (comment)

  • Issue: Fixing Copy on Writes from reference counting and immortal objects #84436

Sorry, something went wrong.

Uh oh!

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

All reactions
@eduardo-elizondo
Implement _PyObject_HEAD_IMMORTAL_INIT and _PyVarObject_HEAD_IMMORTAL…
c63f372
…_INIT
@eduardo-elizondo
eduardo-elizondo requested review from a team, 1st1, abalkin, asvetlov, berkerpeksag, corona10, erlend-aasland, ethanfurman, gvanrossum, iritkatriel, kumaraditya303, markshannon, methane, pganssle, rhettinger and tiran as code owners April 6, 2023 05:32
@bedevere-bot bedevere-bot mentioned this pull request Apr 6, 2023
Fixing Copy on Writes from reference counting and immortal objects #84436
Closed
@bedevere-bot bedevere-bot added the awaiting review label Apr 6, 2023
@eduardo-elizondo eduardo-elizondo changed the title gh-84436: Implement _PyObject_HEAD_IMMORTAL_INIT and _PyVarObject_HEAD_IMMORTAL… gh-84436: Add codemod for _PyVarObject_HEAD_IMMORTAL_INIT Apr 6, 2023
@eduardo-elizondo
Add blurb
5202592
@arhadthedev arhadthedev added interpreter-core (Objects, Python, Grammar, and Parser dirs) extension-modules C modules in the Modules dir labels Apr 6, 2023
@eduardo-elizondo
Regen clinic
26f9e65
@eduardo-elizondo eduardo-elizondo mentioned this pull request Apr 6, 2023
gh-84436: Implement Immortal Objects #19474
Merged
@zooba

zooba commented Apr 6, 2023

Copy link
Copy Markdown
Member

I assume someone is going to review each of these to determine whether they're in the right places? (e.g. the public docs should not be using an internal macro)

If we really do want to update every single use, well, that's why we have the original macro. We should just change it.

My understanding of immortal objects is that we'd carefully opt-in certain types, and not do a global find/replace like this. But possibly the design has changed in a way I haven't kept up with.

At the very least, if it belongs in public docs, make it a public macro. And if it applies literally everywhere, just modify the existing macro.

All reactions

Sorry, something went wrong.

Uh oh!

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

gvanrossum
gvanrossum reviewed Apr 6, 2023
View reviewed changes
Comment thread Misc/NEWS.d/next/Core and Builtins/2023-04-06-01-38-55.gh-issue-84436.PXzsBG.rst
@@ -0,0 +1,3 @@
Replace all internal uses of PyVarObject_HEAD_INIT fo
_PyVarObject_HEAD_IMMORTAL_INIT to be able to initialize them as immortal
objects since they live thorughout the entire execution

@gvanrossum gvanrossum Apr 6, 2023

Copy link
Copy Markdown
Member

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.

Typo

Suggested change
objects since they live thorughout the entire execution
objects since they live throughout the entire execution

Sorry, something went wrong.

Uh oh!

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

All reactions
gvanrossum
gvanrossum reviewed Apr 6, 2023
View reviewed changes

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

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.

Like Steve, I do wonder, why not change the macro instead of 150+ files?

If the macro needs to remain different, could we define the macro different when Py_BUILD_CORE is set?

Sorry, something went wrong.

Uh oh!

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

All reactions
@rhettinger
rhettinger removed their request for review April 6, 2023 18:23
@eduardo-elizondo

eduardo-elizondo commented Apr 8, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor Author

carefully opt-in certain types, and not do a global find/replace like this

@zooba We are opting in all static objects as they live throughout the entire execution of the runtime!

All reactions

Sorry, something went wrong.

Uh oh!

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

@eduardo-elizondo

eduardo-elizondo commented Apr 8, 2023 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor Author

Like Steve, I do wonder, why not change the macro instead of 150+ files?

@zooba @gvanrossum the main goal was to not change the expectations of the public C-API of PyObject_HEAD_INIT and PyVarObject_HEAD_INIT. I think that it should use the immortal value by default but given that this is a public C-API, the goal was to minimize the number of 'disruptive' changes (though it should still be compatible backwards compatible).

All that said, the solution of using Py_BUILD_CORE works really nicely so I'll incorporate that in the main PR and close this PR. Whether we change the default to be immortal or not, I'll leave that to a future discussion (unless anyone has strong opinions otherwise 🙂 )

All reactions

Sorry, something went wrong.

Uh oh!

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

@eduardo-elizondo eduardo-elizondo closed this Apr 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gvanrossum gvanrossum gvanrossum left review comments
@corona10 corona10 Awaiting requested review from corona10
@ethanfurman ethanfurman Awaiting requested review from ethanfurman
@berkerpeksag berkerpeksag Awaiting requested review from berkerpeksag
@erlend-aasland erlend-aasland Awaiting requested review from erlend-aasland erlend-aasland is a code owner
@pganssle pganssle Awaiting requested review from pganssle pganssle is a code owner
@abalkin abalkin Awaiting requested review from abalkin
@tiran tiran Awaiting requested review from tiran
@iritkatriel iritkatriel Awaiting requested review from iritkatriel iritkatriel is a code owner
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner
@methane methane Awaiting requested review from methane methane is a code owner
@1st1 1st1 Awaiting requested review from 1st1 1st1 is a code owner
@asvetlov asvetlov Awaiting requested review from asvetlov
@kumaraditya303 kumaraditya303 Awaiting requested review from kumaraditya303 kumaraditya303 is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

awaiting review extension-modules C modules in the Modules dir interpreter-core (Objects, Python, Grammar, and Parser dirs)

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.

5 participants

@eduardo-elizondo @zooba @gvanrossum @arhadthedev @bedevere-bot
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 01402503 — 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.