There is an issue #92810 - isinstance(ABC_subclass, ...)/issubclass(ABC_subclass, ...) can consume gigabytes of RAM if few thousand unlrelated classes are created and compared with each other. There are 4 related PRs:
- additional tests for
isinstance/issubclasscached and non-cached runs, no code changes https://github.com/python/cpython/pull/144941 - Implementation 1 https://github.com/python/cpython/pull/131914
- Implementation 2 https://github.com/python/cpython/pull/141171
- Implementation 3 https://github.com/python/cpython/pull/150540
The main question here “should ABC.__subclasses__override influence the behavior of isinstance/issubclass” - overriding __subclasses__ for a regular classes (with no metaclass) have no influence in isinstance/issubclass behavior. If answer is “no”, then Implementation 3 is recommended.
I haven’t found any examples on Github where __subclassess__ are overriden, other than Mocks and custom metaclasses.
A review would be appreciated.