Skip to content

Conversation

@bedevere-app bedevere-app bot added docs Documentation in the Doc dir skip news labels Dec 4, 2025
@github-project-automation github-project-automation bot moved this to Todo in Docs PRs Dec 4, 2025
@colesbury colesbury changed the title gh-12324: Document restrictions for tp_traverse implementations gh-123241: Document restrictions for tp_traverse implementations Dec 4, 2025
@colesbury colesbury marked this pull request as ready for review December 4, 2025 21:49
Copy link
Contributor

@mpage mpage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@encukou
Copy link
Member

encukou commented Dec 5, 2025

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.
I assume there can't be a period of deprecation warnings. Does this need a PEP 387 exception?

@pablogsal
Copy link
Member

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.

I assume there can't be a period of deprecation warnings. Does this need a PEP 387 exception?

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.

@DinoV
Copy link
Contributor

DinoV commented Dec 5, 2025

Arguably the "create or destroy" objects is redundant given that involves modifying a reference count but LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

5 participants