Commit 6fb51f2
_Py_Dealloc() fetched the current thread state and computed the C
recursion margin on every deallocation, but both are only used by the
trashcan mechanism, which applies only to GC-tracked types. Gate them
behind the Py_TPFLAGS_HAVE_GC check so the common non-GC case (int,
float, str and similar atomic types) skips them.
On platforms where _PyThreadState_GET() reads a _Thread_local via a
function call (e.g. macOS TLV), this removes a call from every non-GC
deallocation.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent a2a8466 commit 6fb51f2
2 files changed
Lines changed: 15 additions & 6 deletions
File tree
- Misc/NEWS.d/next/Core_and_Builtins
- Objects
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3292 | 3292 | | |
3293 | 3293 | | |
3294 | 3294 | | |
3295 | | - | |
3296 | | - | |
3297 | | - | |
3298 | | - | |
3299 | | - | |
| 3295 | + | |
| 3296 | + | |
| 3297 | + | |
| 3298 | + | |
| 3299 | + | |
| 3300 | + | |
| 3301 | + | |
| 3302 | + | |
| 3303 | + | |
3300 | 3304 | | |
3301 | 3305 | | |
| 3306 | + | |
| 3307 | + | |
| 3308 | + | |
3302 | 3309 | | |
3303 | 3310 | | |
3304 | 3311 | | |
| |||
3340 | 3347 | | |
3341 | 3348 | | |
3342 | 3349 | | |
3343 | | - | |
| 3350 | + | |
3344 | 3351 | | |
3345 | 3352 | | |
3346 | 3353 | | |
| |||
0 commit comments