8000 gh-132657: Avoid locking in frozenset.__contains__ (#132659) · python/cpython@e77d678 · GitHub
[go: up one dir, main page]

Skip to content

Commit e77d678

Browse files
authored
gh-132657: Avoid locking in frozenset.__contains__ (#132659)
1 parent 678b8e1 commit e77d678

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

Objects/clinic/setobject.c.h

Lines changed: 23 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Objects/setobject.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2253,6 +2253,28 @@ set___contains___impl(PySetObject *so, PyObject *key)
22532253
return PyBool_FromLong(result);
22542254
}
22552255

2256+
/*[clinic input]
2257+
@coexist
2258+
frozenset.__contains__
2259+
so: setobject
2260+
object as key: object
2261+
/
2262+
2263+
x.__contains__(y) <==> y in x.
2264+
[clinic start generated code]*/
2265+
2266+
static PyObject *
2267+
frozenset___contains___impl(PySetObject *so, PyObject *key)
2268+
/*[clinic end generated code: output=2301ed91bc3a6dd5 input=2f04922a98d8bab7]*/
2269+
{
2270+
long result;
2271+
2272+
result = set_contains_lock_held(so, key);
2273+
if (result < 0)
2274+
return NULL;
2275+
return PyBool_FromLong(result);
2276+
}
2277+
22562278
/*[clinic input]
22572279
@critical_section
22582280
set.remove
@@ -2555,7 +2577,7 @@ PyTypeObject PySet_Type = {
25552577

25562578

25572579
static PyMethodDef frozenset_methods[] = {
2558-
SET___CONTAINS___METHODDEF
2580+
FROZENSET___CONTAINS___METHODDEF
25592581
FROZENSET_COPY_METHODDEF
25602582
SET_DIFFERENCE_MULTI_METHODDEF
25612583
SET_INTERSECTION_MULTI_METHODDEF

0 commit comments

Comments
 (0)
0