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

gh-126907: Use a list foratexit callbacks#127935

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
kumaraditya303 merged 19 commits intopython:mainfromZeroIntensity:atexit-nogil
Dec 16, 2024

Conversation

@ZeroIntensity
Copy link
Member

@ZeroIntensityZeroIntensity commentedDec 14, 2024
edited by bedevere-appbot
Loading

cc@colesbury,@vstinner,@kumaraditya303

This is an alternative togh-126908, and I'm a lot happier with this. Sam's suggestion of using a list turned out to be pretty nice, with the exception ofunregister being a little wonky. I suspect we could improve that a little by adding a private API for removing from a list more cleanly, but that's work for later. FWIW, both this PR and the other one will have trouble backporting due to the runtime structure changing size.

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.

I like the overall change. Here is a first review.

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.

LGTM

Co-authored-by: Victor Stinner <vstinner@python.org>
@kumaraditya303kumaraditya303enabled auto-merge (squash)December 16, 2024 19:02
@kumaraditya303kumaraditya303 merged commit3b76682 intopython:mainDec 16, 2024
41 checks passed
@ZeroIntensityZeroIntensity deleted the atexit-nogil branchDecember 16, 2024 19:31
@vstinner
Copy link
Member

Congrats@ZeroIntensity for this nice fix!

ZeroIntensity reacted with heart emoji

kumaraditya303 added a commit to kumaraditya303/cpython that referenced this pull requestDec 17, 2024
…127935)Co-authored-by: Victor Stinner <vstinner@python.org>Co-authored-by: Kumar Aditya <kumaraditya@python.org>
kumaraditya303 added a commit to kumaraditya303/cpython that referenced this pull requestDec 17, 2024
…127935)Co-authored-by: Victor Stinner <vstinner@python.org>Co-authored-by: Kumar Aditya <kumaraditya@python.org>
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull requestJan 8, 2025
…127935)Co-authored-by: Victor Stinner <vstinner@python.org>Co-authored-by: Kumar Aditya <kumaraditya@python.org>
@devdanzin
Copy link
Member

Should this be backported or is it not worth it?

@ZeroIntensity
Copy link
MemberAuthor

To 3.13? I don't think it's worth risking breakage.

vstinner reacted with thumbs up emoji

vbraun pushed a commit to vbraun/sage that referenced this pull requestOct 26, 2025
sagemathgh-41021: Refactor ``atexit.pyx``    <!-- ^ Please provide a concise and informative title. --><!-- ^ Don't put issue numbers in the title, do this in the PRdescription below. --><!-- ^ For example, instead of "Fixessagemath#12345" use "Introduce new methodto calculate 1 + 2". --><!-- v Describe your changes below in detail. --><!-- v Why is this change required? What problem does it solve? --><!-- v If this PR resolves an open issue, please link to it here. Forexample, "Fixessagemath#12345". -->I have refactor the ``atexit.pyx`` since for python 3.14, the changes of``atexit`` is so much for supporting the nogil version.### Python<=3.13 Implementation:- The ``atexit`` module stores callbacks in a C array of structs(``atexit_callback``).- The structure is defined in C as:```typedef struct {  PyObject *func;    PyObject *args;    PyObject *kwargs;} atexit_callback;```- Callbacks are stored in the interp->atexit.callbacks field as a Carray- The array can be directly accessed from Cython code using pointerarithmetic### Python 3.14 Implementation:- The ``atexit`` module was refactored to use a Python ``PyList`` objectinstead of a C array.- The structure is now:```state.callbacks = [(func, args, kwargs), ...]  # A Python list of tuples```- In the C implementation, callbacks are managed with:```PyObject *callbacks;  // This is now a PyList```- Callbacks are inserted at the beginning (LIFO order) using``PyList_Insert(state->callbacks, 0, callback)``### 📝 Checklist<!-- Put an `x` in all the boxes that apply. -->- [x] The title is concise and informative.- [x] The description explains in detail what this PR is about.- [x] I have linked a relevant issue or discussion.- [ ] I have created tests covering the changes.- [ ] I have updated the documentation and checked the documentationpreview.### ⌛ Dependencies<!-- List all open PRs that this PR logically depends on. For example,--><!-- -sagemath#12345: short description why this is a dependency --><!-- -sagemath#34567: ... -->python/cpython@3b7668284d4461afpython/cpython#127935    URL:sagemath#41021Reported by: Chenxin ZhongReviewer(s): Copilot, da-woods
vbraun pushed a commit to vbraun/sage that referenced this pull requestOct 26, 2025
sagemathgh-41021: Refactor ``atexit.pyx``    <!-- ^ Please provide a concise and informative title. --><!-- ^ Don't put issue numbers in the title, do this in the PRdescription below. --><!-- ^ For example, instead of "Fixessagemath#12345" use "Introduce new methodto calculate 1 + 2". --><!-- v Describe your changes below in detail. --><!-- v Why is this change required? What problem does it solve? --><!-- v If this PR resolves an open issue, please link to it here. Forexample, "Fixessagemath#12345". -->I have refactor the ``atexit.pyx`` since for python 3.14, the changes of``atexit`` is so much for supporting the nogil version.### Python<=3.13 Implementation:- The ``atexit`` module stores callbacks in a C array of structs(``atexit_callback``).- The structure is defined in C as:```typedef struct {  PyObject *func;    PyObject *args;    PyObject *kwargs;} atexit_callback;```- Callbacks are stored in the interp->atexit.callbacks field as a Carray- The array can be directly accessed from Cython code using pointerarithmetic### Python 3.14 Implementation:- The ``atexit`` module was refactored to use a Python ``PyList`` objectinstead of a C array.- The structure is now:```state.callbacks = [(func, args, kwargs), ...]  # A Python list of tuples```- In the C implementation, callbacks are managed with:```PyObject *callbacks;  // This is now a PyList```- Callbacks are inserted at the beginning (LIFO order) using``PyList_Insert(state->callbacks, 0, callback)``### 📝 Checklist<!-- Put an `x` in all the boxes that apply. -->- [x] The title is concise and informative.- [x] The description explains in detail what this PR is about.- [x] I have linked a relevant issue or discussion.- [ ] I have created tests covering the changes.- [ ] I have updated the documentation and checked the documentationpreview.### ⌛ Dependencies<!-- List all open PRs that this PR logically depends on. For example,--><!-- -sagemath#12345: short description why this is a dependency --><!-- -sagemath#34567: ... -->python/cpython@3b7668284d4461afpython/cpython#127935    URL:sagemath#41021Reported by: Chenxin ZhongReviewer(s): Copilot, da-woods
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@vstinnervstinnervstinner approved these changes

@kumaraditya303kumaraditya303kumaraditya303 approved these changes

@ericsnowcurrentlyericsnowcurrentlyAwaiting requested review from ericsnowcurrentlyericsnowcurrently is a code owner

Assignees

@kumaraditya303kumaraditya303

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@ZeroIntensity@vstinner@devdanzin@kumaraditya303

[8]ページ先頭

©2009-2025 Movatter.jp