mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-132657: Avoid locking in frozenset.__contains__ (#132659)
This commit is contained in:
parent
678b8e1656
commit
e77d6784e7
2 changed files with 46 additions and 2 deletions
24
Objects/clinic/setobject.c.h
generated
24
Objects/clinic/setobject.c.h
generated
|
@ -432,6 +432,28 @@ set___contains__(PyObject *so, PyObject *key)
|
|||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(frozenset___contains____doc__,
|
||||
"__contains__($self, object, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"x.__contains__(y) <==> y in x.");
|
||||
|
||||
#define FROZENSET___CONTAINS___METHODDEF \
|
||||
{"__contains__", (PyCFunction)frozenset___contains__, METH_O|METH_COEXIST, frozenset___contains____doc__},
|
||||
|
||||
static PyObject *
|
||||
frozenset___contains___impl(PySetObject *so, PyObject *key);
|
||||
|
||||
static PyObject *
|
||||
frozenset___contains__(PyObject *so, PyObject *key)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
|
||||
return_value = frozenset___contains___impl((PySetObject *)so, key);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(set_remove__doc__,
|
||||
"remove($self, object, /)\n"
|
||||
"--\n"
|
||||
|
@ -532,4 +554,4 @@ set___sizeof__(PyObject *so, PyObject *Py_UNUSED(ignored))
|
|||
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=e2f1470de062d661 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=7f7fe845ca165078 input=a9049054013a1b77]*/
|
||||
|
|
|
@ -2253,6 +2253,28 @@ set___contains___impl(PySetObject *so, PyObject *key)
|
|||
return PyBool_FromLong(result);
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
@coexist
|
||||
frozenset.__contains__
|
||||
so: setobject
|
||||
object as key: object
|
||||
/
|
||||
|
||||
x.__contains__(y) <==> y in x.
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
frozenset___contains___impl(PySetObject *so, PyObject *key)
|
||||
/*[clinic end generated code: output=2301ed91bc3a6dd5 input=2f04922a98d8bab7]*/
|
||||
{
|
||||
long result;
|
||||
|
||||
result = set_contains_lock_held(so, key);
|
||||
if (result < 0)
|
||||
return NULL;
|
||||
return PyBool_FromLong(result);
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
@critical_section
|
||||
set.remove
|
||||
|
@ -2555,7 +2577,7 @@ PyTypeObject PySet_Type = {
|
|||
|
||||
|
||||
static PyMethodDef frozenset_methods[] = {
|
||||
SET___CONTAINS___METHODDEF
|
||||
FROZENSET___CONTAINS___METHODDEF
|
||||
FROZENSET_COPY_METHODDEF
|
||||
SET_DIFFERENCE_MULTI_METHODDEF
|
||||
SET_INTERSECTION_MULTI_METHODDEF
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue