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

Use member names to initialize PyTypeObjects #8741

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

radarhere
Copy link
Member

Borrowing an idea from #5201. Similar to #8734

As shown at https://docs.python.org/3/c-api/typeobj.html#examples, this uses member names to initialize PyTypeObjects, rather than being verbose and going through every member in sequence.

Also, I've removed specifying tp_flags as Py_TPFLAGS_DEFAULT, and so instead using the actual default from https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_flags, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE.

https://docs.python.org/3/c-api/typeobj.html#c.Py_TPFLAGS_BASETYPE

Py_TPFLAGS_BASETYPE
This bit is set when the type can be used as the base type of another type. If this bit is clear, the type cannot be subtyped (similar to a “final” class in Java).

I don't think we really need to specify that they can't be subtyped.

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

Successfully merging this pull request may close these issues.

1 participant