Skip to content

bpo-45697: PyType_IsSubtype: Return early for identical type objects#29380

Closed
itamaro wants to merge 1 commit into
python:mainfrom
itamaro:bpo-45697-is-subtype-optimization
Closed

bpo-45697: PyType_IsSubtype: Return early for identical type objects#29380
itamaro wants to merge 1 commit into
python:mainfrom
itamaro:bpo-45697-is-subtype-optimization

Conversation

@itamaro
Copy link
Copy Markdown
Contributor

@itamaro itamaro commented Nov 3, 2021

bpo-45697: PyType_IsSubtype: Return early for identical type objects

Based on real world profiling data we collected, a vast amount of PyType_IsSubtype calls are coming from type_call, when it decides whether __init__ should run or not.

In the common case, the arguments to this call are identical, but the implementation still walks the MRO.

By returning early for identical types, the common case can be optimized with a non-trivial performance gain.

https://bugs.python.org/issue45697

@itamaro
Copy link
Copy Markdown
Contributor Author

itamaro commented Nov 3, 2021

superseded by GH-29392

@itamaro itamaro closed this Nov 3, 2021
@itamaro itamaro deleted the bpo-45697-is-subtype-optimization branch March 22, 2023 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants