Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add PyUnstable_Object_IsUniquelyReferenced#149

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
vstinner merged 6 commits intopython:mainfromngoldbaum:is-unique
Sep 1, 2025

Conversation

@ngoldbaum
Copy link
Contributor

Adds a shim forPyUnstable_Object_IsUniquelyReferenced and a test for the shim.

I'd like to use this function in a few libraries but don't want to have to have a thread-unsafe check in 3.13 or add new uses of internal headers outside of the compat header here.

I'm not sure whether the using stuff from internal headers is ok in a shim like this. I'm also not sure if you want to avoidPyUnstable functions in the compat headers.

The implementation is copy/pasted from the implementation of_PyObject_IsUniquelyReferenced.

Copy link
Member

@vstinnervstinner left a comment

Choose a reason for hiding this comment

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

Can you please rebase your PR on the updated main branch to get tests on Free Threaded builds?

}
#endif

#ifndefPYPY_VERSION
Copy link
Member

Choose a reason for hiding this comment

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

The function doesn't make sense on PyPy?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Apparently not, maybe an interned string? I rewrote it to use an empty tuple and that seems to work on PyPy.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I rewrote it to use an empty tuple and that seems to work on PyPy.

but that seems to have broken other builds, let me see if I can get it working everywhere...

@vstinner
Copy link
Member

Tests fail on Python 2:

python2.7: test_pythoncapi_compat_cext.c:1983: test_uniquely_referenced: Assertion `PyUnstable_Object_IsUniquelyReferenced(obj)' failed.

@ngoldbaum
Copy link
ContributorAuthor

Tests fail on Python 2

I guess empty tuples have had reference counting optimizations for a long time!

@vstinner
Copy link
Member

Please update also the doc:

  • docs/changelog.rst
  • docs/api.rst
ngoldbaum reacted with thumbs up emoji

@vstinnervstinner merged commit90c06a4 intopython:mainSep 1, 2025
36 checks passed
@vstinner
Copy link
Member

Merged, thanks for your contribution.

I'm not very excited by addingPyUnstable functions to pythoncapi-compat, but I'm fine with this specific function.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@vstinnervstinnervstinner left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@ngoldbaum@vstinner

[8]ページ先頭

©2009-2025 Movatter.jp