Repository navigation
[PERF] Speed up Object instance and subclass checks - #976
Merged
Merged
Conversation
cyx-6
force-pushed
the
codex/object-type-checks
branch
from
November 14, 2026 14:36
beecc22 to
488c7f7
Compare
cyx-6
force-pushed
the
codex/object-type-checks
branch
from
November 14, 2026 14:39
488c7f7 to
396c93f
Compare
tqchen
approved these changes
Nov 14, 2026
tqchen
requested changes
Nov 14, 2026
| # Until one is, ``isinstance`` and ``issubclass`` against an Object class follow the MRO alone, which | ||
| # is what ``ABCMeta`` answers then too, without its Python-level check: a negative ``issubclass`` | ||
| # there walks every subclass of the class, adding overhead for large class hierarchies. | ||
| cdef bint _OBJECT_ABC_VIRTUAL = False |
Member
There was a problem hiding this comment.
would be good to add an short example explaination of the checks
tqchen
approved these changes
Nov 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Object instance and subclass checks incur ABCMeta overhead even when no virtual subclasses are registered. Negative subclass checks can recursively traverse large class hierarchies.
Use MRO checks for Object instance and subclass checks, falling back to ABCMeta when virtual subclasses are registered or a subclass hook is defined. Add coverage for non-Object values, collection ABCs, virtual subclasses, and subclass hooks.