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 — Add PyUnstable_SetImmortal by kumaraditya303 · Pull Request #164 · python/pythoncapi-compat

Conversation

@kumaraditya303

@kumaraditya303 kumaraditya303 commented Feb 12, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Sorry, something went wrong.

Uh oh!

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

All reactions
@kumaraditya303
kumaraditya303 force-pushed the main branch from 58b73a1 to 1722f86 Compare February 12, 2026 12:01
vstinner
vstinner reviewed Feb 12, 2026
View reviewed changes

@vstinner vstinner 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.

Please document the new function in docs/changelog.rst and docs/api.rst.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread tests/test_pythoncapi_compat_cext.c Resolved

Uh oh!

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

@kumaraditya303
kumaraditya303 force-pushed the main branch from 1722f86 to b102df8 Compare February 12, 2026 12:10
@kumaraditya303
Add PyUnstable_SetImmortal
a57ea4e
@kumaraditya303
kumaraditya303 force-pushed the main branch from b102df8 to a57ea4e Compare February 12, 2026 12:12
kumaraditya303 added 2 commits February 12, 2026 17:47
@kumaraditya303
restrict to 3.14
36c4507
@kumaraditya303
add docs
c201d29
@kumaraditya303
kumaraditya303 marked this pull request as ready for review February 12, 2026 12:32
@kumaraditya303
kumaraditya303 requested a review from vstinner February 12, 2026 12:35
vstinner
vstinner reviewed Feb 12, 2026
View reviewed changes
Comment thread docs/api.rst Resolved

Uh oh!

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

Comment thread pythoncapi_compat.h Resolved

Uh oh!

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

kumaraditya303 and others added 2 commits February 12, 2026 18:11
@kumaraditya303 @vstinner
Update pythoncapi_compat.h
e2bac98
Co-authored-by: Victor Stinner <[email protected]>
@kumaraditya303
add availability
9103321
vstinner
vstinner reviewed Feb 12, 2026
View reviewed changes
Comment thread pythoncapi_compat.h Resolved

Uh oh!

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

kumaraditya303 added 3 commits February 12, 2026 18:53
@kumaraditya303
add support for 3.13
3ccded6
@kumaraditya303
fix 3.14
0280559
@kumaraditya303
fmt
3eae7cb
@kumaraditya303
kumaraditya303 requested a review from vstinner February 12, 2026 13:50
vstinner
vstinner reviewed Feb 12, 2026
View reviewed changes

@vstinner vstinner 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.

I agree to not add Python 3.12 support.

It's tempting to add Python 3.12 support, but Python 3.12 semantics is different:

static inline void _Py_SetImmortal(PyObject *op)
{
    if (op) {
        op->ob_refcnt = _Py_IMMORTAL_REFCNT;
    }
}
  • Different API: it has no return value (void)!
  • It doesn't reject Unicode objects.
  • It doesn't untrack objects in the GC.
// Immortal objects were implemented in Python 3.12, however there is no easy API
// to make objects immortal until 3.14 which has _Py_SetImmortal(). Since
// immortal objects are primarily needed for free-threading, this API is implemented
// for 3.14 using _Py_SetImmortal() and uses private macros on 3.13.

I agree that PyUnstable_SetImmortal() is mostly useful on free-threaded builds, so it's ok to skip Python 3.12.

Sorry, something went wrong.

Uh oh!

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

All reactions
vstinner
vstinner approved these changes Feb 12, 2026
View reviewed changes

@vstinner vstinner 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.

LGTM.

Sorry, something went wrong.

Uh oh!

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

All reactions
@vstinner

vstinner commented Feb 12, 2026

Copy link
Copy Markdown
Member

Good, the tests passed successfully on Python 3.13 on regular build and free-threaded build:

  • Build / build (macos-latest, 3.13) (pull_request)
  • Build / build (macos-latest, 3.13t) (pull_request)
All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner
vstinner merged commit 8636bcc into python:main Feb 12, 2026
36 checks passed

Uh oh!

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

@vstinner vstinner mentioned this pull request Feb 12, 2026
gh-143300: implement PyUnstable_SetImmortal python/cpython#144543
Merged
ngoldbaum
ngoldbaum reviewed Feb 12, 2026
View reviewed changes
Comment thread pythoncapi_compat.h Resolved

Uh oh!

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

This was referenced Feb 12, 2026
BUG: Multithreaded scaling bottlenecks on free-threaded Python numpy/numpy#30494
Closed
Make intern! & py_format! strings immortal PyO3/pyo3#5794
Draft
@ngoldbaum ngoldbaum mentioned this pull request Feb 20, 2026
Add bindings for PyUnstable 3.14 APIs PyO3/pyo3#5828
Merged
@luxedo luxedo mentioned this pull request Feb 21, 2026
Add PyUnstable compat API for PyUnstable_Object_IsUniquelyReferenced and PyUnstable_SetImmortal PyO3/pyo3#5834
Open
@eendebakpt eendebakpt mentioned this pull request Mar 12, 2026
Draft: ENH: Make dtypes immortal numpy/numpy#30993
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner approved these changes
+1 more reviewer
@ngoldbaum ngoldbaum ngoldbaum left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

No one assigned

Labels

None yet

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.

3 participants

@kumaraditya303 @vstinner @ngoldbaum
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.