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-143300: implement `PyUnstable_SetImmortal` by kumaraditya303 · Pull Request #144543 · python/cpython

Conversation

@kumaraditya303

@kumaraditya303 kumaraditya303 commented Feb 6, 2026 •
edited by github-actions Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor
  • Issue: Add an unstable C API for immortalizing objects #143300

📚 Documentation preview 📚: https://cpython-previews--144543.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

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

All reactions
@kumaraditya303
implement PyUnstable_SetImmortal
b874f0b
@bedevere-app bedevere-app Bot mentioned this pull request Feb 6, 2026
Add an unstable C API for immortalizing objects #143300
Closed
@kumaraditya303
fix compilation under ft
cb6cc99
eendebakpt
eendebakpt reviewed Feb 6, 2026
View reviewed changes
Comment thread Doc/c-api/object.rst Resolved

Uh oh!

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

eendebakpt
eendebakpt reviewed Feb 6, 2026
View reviewed changes
Comment thread Doc/c-api/object.rst Resolved

Uh oh!

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

ngoldbaum
ngoldbaum reviewed Feb 6, 2026
View reviewed changes
Comment thread Objects/object.c Resolved

Uh oh!

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

@kumaraditya303
minor fixes
c897a08
ZeroIntensity
ZeroIntensity reviewed Feb 8, 2026
View reviewed changes

@ZeroIntensity ZeroIntensity 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 think we also need to document the guarantees regarding which objects may be made immortal. For example, the following results in an assertion failure:

from ctypes import pythonapi, py_object, c_int

set_immortal = pythonapi.PyUnstable_SetImmortal
set_immortal.argtypes = (py_object,)
set_immortal.restype = c_int

print(set_immortal("Hello world"))

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Doc/c-api/object.rst Resolved

Uh oh!

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

Comment thread Doc/c-api/object.rst Resolved

Uh oh!

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

Comment thread Doc/c-api/object.rst Resolved

Uh oh!

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

Comment thread Objects/object.c Resolved

Uh oh!

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

kumaraditya303 and others added 3 commits February 10, 2026 19:02
@kumaraditya303 @ZeroIntensity
Apply suggestions from code review
f00e23f
Co-authored-by: Peter Bierma <[email protected]>
@kumaraditya303
address review
f42377a
@kumaraditya303
Merge branch 'main' into immortal
ed5389c
ZeroIntensity
ZeroIntensity reviewed Feb 10, 2026
View reviewed changes

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

Looks pretty good.

Bikeshedding: Should this be named PyUnstable_Object_SetImmortal? The Py[Unstable]_ prefix is generally reserved for runtime operations (though it seems PyUnstable_TryIncRef didn't follow that rule).

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Doc/c-api/object.rst Resolved

Uh oh!

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

@kumaraditya303
add more tests
9987a92
@kumaraditya303

kumaraditya303 commented Feb 10, 2026

Copy link
Copy Markdown
Contributor Author

Should this be named PyUnstable_Object_SetImmortal?

I'd like to keep it aligned with PyObject_IsImmortal and avoid introducing the Object in between.

ZeroIntensity reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@kumaraditya303
kumaraditya303 marked this pull request as ready for review February 10, 2026 14:11
@bedevere-app bedevere-app Bot added the awaiting core review label Feb 10, 2026
kumaraditya303 added 2 commits February 10, 2026 20:33
@kumaraditya303
fix test on ft
9a4003c
@kumaraditya303
fix lint
8fe0fb5
ZeroIntensity
ZeroIntensity reviewed Feb 10, 2026
View reviewed changes
Comment thread Doc/c-api/object.rst Resolved

Uh oh!

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

@kumaraditya303
address final review
a146bef
@kumaraditya303
kumaraditya303 force-pushed the immortal branch from 9d262b1 to a146bef Compare February 11, 2026 13:27
@blurb-it
📜🤖 Added by blurb_it.
e1ef13d
@kumaraditya303
kumaraditya303 requested a review from ZeroIntensity February 11, 2026 13:31
ZeroIntensity
ZeroIntensity approved these changes Feb 11, 2026
View reviewed changes

@ZeroIntensity ZeroIntensity 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
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Feb 11, 2026
@kumaraditya303
kumaraditya303 merged commit 347d359 into python:main Feb 11, 2026
51 checks passed

Uh oh!

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

@kumaraditya303
kumaraditya303 deleted the immortal branch February 11, 2026 15:29
@bedevere-app bedevere-app Bot removed the awaiting merge label Feb 11, 2026
@ngoldbaum ngoldbaum mentioned this pull request Feb 11, 2026
BUG: Multithreaded scaling bottlenecks on free-threaded Python numpy/numpy#30494
Closed
@vstinner

vstinner commented Feb 12, 2026

Copy link
Copy Markdown
Member

Kumar also added PyUnstable_SetImmortal() function for Python 3.13 and 3.14 in pythoncapi-compat: python/pythoncapi-compat#164.

All reactions

Sorry, something went wrong.

Uh oh!

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

thunder-coding pushed a commit to thunder-coding/cpython that referenced this pull request Feb 15, 2026
@kumaraditya303 @thunder-coding
pythongh-143300: implement PyUnstable_SetImmortal for marking objec…
fa84fb6
…ts as immortal (python#144543)
brijkapadia pushed a commit to brijkapadia/cpython that referenced this pull request Feb 28, 2026
@kumaraditya303 @brijkapadia
pythongh-143300: implement PyUnstable_SetImmortal for marking objec…
2ce2e1e
…ts as immortal (python#144543)
@kumaraditya303 kumaraditya303 added the topic-free-threading label Mar 29, 2026
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
@kumaraditya303 @ljfp
pythongh-143300: implement PyUnstable_SetImmortal for marking objec…
4e03924
…ts as immortal (python#144543)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@eendebakpt eendebakpt eendebakpt left review comments
@ngoldbaum ngoldbaum ngoldbaum left review comments
@ZeroIntensity ZeroIntensity ZeroIntensity approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

topic-free-threading

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

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