-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
gh-123241: Document restrictions for tp_traverse implementations
#142272
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
base: main
Are you sure you want to change the base?
Conversation
d248354 to
c390756
Compare
tp_traverse implementationstp_traverse implementations
mpage
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
If we just add it to the docs like this, how are maintainers of old code expected to find out about it? AFAICS, this is a new requirement, and making CPython rely on it will be a breaking change. |
This was unfortunately always a requirement for correctness but we never documented it. Calling it a "new requirement" is probably not very productive because if you were doing this before you have a bug and you can affect the correctness of the algorithm or crash depending on the version and the situation. We could perhaps raise some warnings with time time cost in debug build by checking the total ref count. |
|
Arguably the "create or destroy" objects is redundant given that involves modifying a reference count but LGTM. |
📚 Documentation preview 📚: https://cpython-previews--142272.org.readthedocs.build/
Py_INCREF()/Py_DECREF()intp_traversehandlers #123241