Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-44531: Add _PyType_AllocNoTrack() function #26947

Merged
merged 1 commit into from Jul 1, 2021

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Jun 29, 2021

Add an internal _PyType_AllocNoTrack() function to allocate an object
without tracking it in the GC.

Modify dict_new() to use _PyType_AllocNoTrack(): dict subclasses are
now only tracked once all PyDictObject members are initialized.
Calling _PyObject_GC_UNTRACK() is no longer needed for the dict type.

Similar change in tuple_subtype_new() for tuple subclasses.

Replace tuple_gc_track() with _PyObject_GC_TRACK().

https://bugs.python.org/issue44531

Add an internal _PyType_AllocNoTrack() function to allocate an object
without tracking it in the GC.

Modify dict_new() to use _PyType_AllocNoTrack(): dict subclasses are
now only tracked once all PyDictObject members are initialized.
Calling _PyObject_GC_UNTRACK() is no longer needed for the dict type.

Similar change in tuple_subtype_new() for tuple subclasses.

Replace tuple_gc_track() with _PyObject_GC_TRACK().
@vstinner
Copy link
Member Author

@vstinner vstinner commented Jun 29, 2021

cc @methane @pablogsal: Would you mind to review this change?

dict_new() and tuple_subtype_new() detect if a subclass overrides tp_alloc. IMO it's possible and so it's safer to detect it: check _PyObject_GC_IS_TRACKED().

@vstinner vstinner merged commit 818628c into python:main Jul 1, 2021
12 checks passed
12 checks passed
@github-actions
Check for source changes
Details
@github-actions
Check if generated files are up to date
Details
@github-actions
Windows (x86)
Details
@github-actions
Windows (x64)
Details
@github-actions
macOS
Details
@github-actions
Ubuntu
Details
@github-actions
Ubuntu SSL tests with OpenSSL
Details
@github-actions
Address sanitizer Address sanitizer
Details
Azure Pipelines PR #20210629.3 succeeded
Details
@travis-ci
Travis CI - Pull Request Build Passed
Details
@bedevere-bot
bedevere/issue-number Issue number 44531 found
Details
@bedevere-bot
bedevere/news "skip news" label found
@vstinner vstinner deleted the vstinner:alloc_no_track branch Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants