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

gh-119180: Alternative approach to metaclass annotations: never use the dict #120816

Closed
wants to merge 1 commit into from

Conversation

JelleZijlstra
Copy link
Member

@JelleZijlstra JelleZijlstra commented Jun 21, 2024

Like #120719, this is an experimental way to fix the issues discussed in python/peps#3847.

This PR takes the approach of "never use the class dict". Instead, we repurpose the unused tp_cache field to hold annotation information. It can hold any of:

  • NULL: the class has no annotations
  • a dict: the class has __annotations__, but no __annotate__
  • a callable: the class has only __annotate__
  • a tuple: the class has both annotate and annotations

@JelleZijlstra
Copy link
Member Author

We'll go with #122074.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant