forked fromsagemath/sage
- Notifications
You must be signed in to change notification settings - Fork0
Commitc162d51
Release Manager
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
1 file changed
+75
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
146 | 147 | | |
147 | | - | |
| 148 | + | |
148 | 149 | | |
149 | 150 | | |
| 151 | + | |
150 | 152 | | |
| 153 | + | |
151 | 154 | | |
152 | 155 | | |
153 | 156 | | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
159 | 168 | | |
160 | 169 | | |
161 | 170 | | |
162 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
163 | 193 | | |
164 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
165 | 198 | | |
166 | 199 | | |
167 | 200 | | |
168 | | - | |
| 201 | + | |
169 | 202 | | |
170 | 203 | | |
171 | 204 | | |
172 | 205 | | |
173 | | - | |
174 | | - | |
175 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
176 | 209 | | |
177 | 210 | | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
191 | 239 | | |
192 | 240 | | |
193 | 241 | | |
| |||
202 | 250 | | |
203 | 251 | | |
204 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
205 | 256 | | |
206 | 257 | | |
207 | 258 | | |
| |||
0 commit comments
Comments
(0)