Skip to content

Commit 0c0934b

Browse files
committed
Convert (frozen)set_copy
1 parent 558e45c commit 0c0934b

File tree

2 files changed

+75
-14
lines changed

2 files changed

+75
-14
lines changed

Objects/clinic/setobject.c.h

Lines changed: 49 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: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@
4444

4545
/*[clinic input]
4646
class set "PySetObject *" "&PySet_Type"
47+
class frozenset "PySetObject *" "&PyFrozenSet_Type"
4748
[clinic start generated code]*/
48-
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=abe13a1b24961902]*/
49+
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=97ad1d3e9f117079]*/
4950

5051
/* Object used as dummy key to fill deleted entries */
5152
static PyObject _dummy_struct;
@@ -1175,23 +1176,37 @@ set_swap_bodies(PySetObject *a, PySetObject *b)
11751176
}
11761177
}
11771178

1179+
/*[clinic input]
1180+
@critical_section
1181+
set.copy
1182+
1183+
Return a shallow copy of a set.
1184+
[clinic start generated code]*/
1185+
11781186
static PyObject *
1179-
set_copy(PySetObject *so, PyObject *Py_UNUSED(ignored))
1187+
set_copy_impl(PySetObject *self)
1188+
/*[clinic end generated code: output=db3ef842e70a8bda input=23f7054e37bee78f]*/
11801189
{
1181-
return make_new_set_basetype(Py_TYPE(so), (PyObject *)so);
1190+
return make_new_set_basetype(Py_TYPE(self), (PyObject *)self);
11821191
}
11831192

1193+
/*[clinic input]
1194+
@critical_section
1195+
frozenset.copy
1196+
1197+
Return a shallow copy of a set.
1198+
[clinic start generated code]*/
1199+
11841200
static PyObject *
1185-
frozenset_copy(PySetObject *so, PyObject *Py_UNUSED(ignored))
1201+
frozenset_copy_impl(PySetObject *self)
1202+
/*[clinic end generated code: output=3ff78c0546ebeafd input=7645c38bf258935c]*/
11861203
{
1187-
if (PyFrozenSet_CheckExact(so)) {
1188-
return Py_NewRef(so);
1204+
if (PyFrozenSet_CheckExact(self)) {
1205+
return Py_NewRef(self);
11891206
}
1190-
return set_copy(so, NULL);
1207+
return set_copy(self, NULL);
11911208
}
11921209

1193-
PyDoc_STRVAR(copy_doc, "Return a shallow copy of a set.");
1194-
11951210
/*[clinic input]
11961211
@critical_section
11971212
set.clear
@@ -2303,8 +2318,7 @@ static PyMethodDef set_methods[] = {
23032318
SET_ADD_METHODDEF
23042319
SET_CLEAR_METHODDEF
23052320
SET___CONTAINS___METHODDEF
2306-
{"copy", (PyCFunction)set_copy, METH_NOARGS,
2307-
copy_doc},
2321+
SET_COPY_METHODDEF
23082322
SET_DISCARD_METHODDEF
23092323
{"difference", (PyCFunction)set_difference_multi, METH_VARARGS,
23102324
difference_doc},
@@ -2428,8 +2442,7 @@ PyTypeObject PySet_Type = {
24282442

24292443
static PyMethodDef frozenset_methods[] = {
24302444
SET___CONTAINS___METHODDEF
2431-
{"copy", (PyCFunction)frozenset_copy, METH_NOARGS,
2432-
copy_doc},
2445+
FROZENSET_COPY_METHODDEF
24332446
{"difference", (PyCFunction)set_difference_multi, METH_VARARGS,
24342447
difference_doc},
24352448
{"intersection", (PyCFunction)set_intersection_multi, METH_VARARGS,

0 commit comments

Comments
 (0)