Skip to content

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.

@hugovk hugovk merged commit a254b8c into python-pillow:main Feb 17, 2025
53 checks passed
@radarhere radarhere deleted the type branch February 17, 2025 20:50
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.

2 participants