Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Immortal objects and the C API docs #104597

Closed
JelleZijlstra opened this issue May 18, 2023 · 8 comments
Closed

Immortal objects and the C API docs #104597

JelleZijlstra opened this issue May 18, 2023 · 8 comments
Labels
docs Documentation in the Doc dir topic-C-API

Comments

@JelleZijlstra
Copy link
Member

https://docs.python.org/3.12/c-api/none.html#c.Py_None currently says that Py_None "needs to be treated just like any other object with respect to reference counts". That's not really true now that we have PEP-683 immortal objects: there is no need to incref/decref it. There are several similar places, e.g. https://docs.python.org/3.12/c-api/slice.html#ellipsis-object and https://docs.python.org/3.12/c-api/bool.html#c.Py_False.

The docs should be updated to somehow refer to the fact that these objects are immortal. However, extension authors who want to retain support for 3.11 and lower should continue to refcount None etc. correctly, so we shouldn't completely omit discussion of refcounting.

cc @eduardo-elizondo

@JelleZijlstra JelleZijlstra added the docs Documentation in the Doc dir label May 18, 2023
@eduardo-elizondo
Copy link
Contributor

Oh that's a great point, let me make a note of this to go through the C-API Docs this weekend and update all the relevant singletons.

Debating whether to add a 3.12 note only or if we should change the whole section to reflect immortality and just have a note for < 3.11

@carljm
Copy link
Member

carljm commented May 18, 2023

Debating whether to add a 3.12 note only or if we should change the whole section to reflect immortality and just have a note for < 3.11

The docs are per-version, so the 3.12 docs should document the state of 3.12. It's good to include a .. versionchanged: 3.12 note, though.

@eduardo-elizondo
Copy link
Contributor

eduardo-elizondo commented Jun 4, 2023

This has now been addressed by @iritkatriel in GH-105195! We can probably close this issue now 🙂

@iritkatriel
Copy link
Member

Sorry I didn't notice this issue. My PR is not reviewed/merged yet though.

@eduardo-elizondo
Copy link
Contributor

My PR is not reviewed/merged yet though.

Ah my bad, you are right, I misread. Alright let's see if we can push your PR to resolve this issue

@vstinner
Copy link
Member

cc @ZeroIntensity

@ZeroIntensity
Copy link
Member

It looks like most of the objects in question have been documented with an immortality note, is there anything else to do here?

@vstinner
Copy link
Member

The docs should be updated to somehow refer to the fact that these objects are immortal.

I confirm that the doc has been updated. I close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir topic-C-API
Projects
None yet
Development

No branches or pull requests

7 participants