From: Kumar Aditya Date: Tue, 11 Nov 2025 14:32:32 +0000 (+0530) Subject: gh-132657: optimize `PySet_Contains` for `frozenset` (#141183) X-Git-Tag: v3.15.0a2~112 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7211a34fe1d9704935342af8c9b46725629f2d97;p=thirdparty%2FPython%2Fcpython.git gh-132657: optimize `PySet_Contains` for `frozenset` (#141183) --- diff --git a/Objects/setobject.c b/Objects/setobject.c index 213bd821d8a1..2401176576eb 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -2747,7 +2747,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);