Skip to content

Commit b657cd6

Browse files
committed
gh-92810: Remove false fastpath
1 parent 2f8f2b2 commit b657cd6

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

Lib/_py_abc.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,11 @@ def __subclasscheck__(cls, subclass):
143143
return True
144144
# Check if it's a subclass of a subclass (recursive)
145145
for scls in cls.__subclasses__():
146-
if subclass is scls:
147-
# Fast path
148-
if not cls._abc_issubclasscheck_recursive:
149-
cls._abc_cache.add(subclass)
150-
return True
151146
# If inside recursive issubclass check, avoid adding classes
152147
# to any cache because this may drastically increase memory usage.
153148
# Unfortunately, issubclass/__subclasscheck__ don't accept third
154149
# argument with context, so using global context within ABCMeta.
155-
# This is done only on first method call, next will use cache.
150+
# This is done only on first method call, next will use cache anyway.
156151
scls_is_abc = hasattr(scls, "_abc_issubclasscheck_recursive")
157152
if scls_is_abc:
158153
scls._abc_issubclasscheck_recursive = True

Modules/_abc.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -854,17 +854,6 @@ _abc__abc_subclasscheck_impl(PyObject *module, PyObject *self,
854854
goto end;
855855
}
856856

857-
if (scls == subclass) {
858-
// Fast path
859-
if (!is_issubclasscheck_recursive(impl)) {
860-
if (_add_to_weak_set(impl, &impl->_abc_cache, subclass) < 0) {
861-
goto end;
862-
}
863-
}
864-
result = Py_True;
865-
goto end;
866-
}
867-
868857
_abc_data *scls_impl;
869858
int scls_is_abc = _get_optional_impl(state, scls, &scls_impl);
870859
if (scls_is_abc < 0) {
@@ -925,7 +914,7 @@ static int
925914
subclasscheck_check_registry(_abc_data *impl, PyObject *subclass,
926915
PyObject **result)
927916
{
928-
// Fast path: check subclass is in weakref directly.
917+
// Fast path: check subclass is in weakset directly.
929918
int ret = _in_weak_set(impl, &impl->_abc_registry, subclass);
930919
if (ret < 0) {
931920
*result = NULL;

0 commit comments

Comments
 (0)