[3.14] gh-132657: optimize PySet_Contains for frozenset (GH-141183) (gh-141773)

(cherry picked from commit 7211a34fe1)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This commit is contained in:
Miss Islington (bot) 2025-11-20 02:01:49 +01:00 committed by GitHub
parent c05e71f61e
commit 072eeaf84c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2746,7 +2746,9 @@ PySet_Contains(PyObject *anyset, PyObject *key)
PyErr_BadInternalCall();
return -1;
}
if (PyFrozenSet_CheckExact(anyset)) {
return set_contains_key((PySetObject *)anyset, key);
}
int rv;
Py_BEGIN_CRITICAL_SECTION(anyset);
rv = set_contains_key((PySetObject *)anyset, key);