/src/cpython/Objects/clinic/setobject.c.h
Line | Count | Source (jump to first uncovered line) |
1 | | /*[clinic input] |
2 | | preserve |
3 | | [clinic start generated code]*/ |
4 | | |
5 | | #include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() |
6 | | |
7 | | PyDoc_STRVAR(set_pop__doc__, |
8 | | "pop($self, /)\n" |
9 | | "--\n" |
10 | | "\n" |
11 | | "Remove and return an arbitrary set element.\n" |
12 | | "\n" |
13 | | "Raises KeyError if the set is empty."); |
14 | | |
15 | | #define SET_POP_METHODDEF \ |
16 | | {"pop", (PyCFunction)set_pop, METH_NOARGS, set_pop__doc__}, |
17 | | |
18 | | static PyObject * |
19 | | set_pop_impl(PySetObject *so); |
20 | | |
21 | | static PyObject * |
22 | | set_pop(PyObject *so, PyObject *Py_UNUSED(ignored)) |
23 | 105 | { |
24 | 105 | PyObject *return_value = NULL; |
25 | | |
26 | 105 | Py_BEGIN_CRITICAL_SECTION(so); |
27 | 105 | return_value = set_pop_impl((PySetObject *)so); |
28 | 105 | Py_END_CRITICAL_SECTION(); |
29 | | |
30 | 105 | return return_value; |
31 | 105 | } |
32 | | |
33 | | PyDoc_STRVAR(set_update__doc__, |
34 | | "update($self, /, *others)\n" |
35 | | "--\n" |
36 | | "\n" |
37 | | "Update the set, adding elements from all others."); |
38 | | |
39 | | #define SET_UPDATE_METHODDEF \ |
40 | | {"update", _PyCFunction_CAST(set_update), METH_FASTCALL, set_update__doc__}, |
41 | | |
42 | | static PyObject * |
43 | | set_update_impl(PySetObject *so, PyObject * const *others, |
44 | | Py_ssize_t others_length); |
45 | | |
46 | | static PyObject * |
47 | | set_update(PyObject *so, PyObject *const *args, Py_ssize_t nargs) |
48 | 0 | { |
49 | 0 | PyObject *return_value = NULL; |
50 | 0 | PyObject * const *others; |
51 | 0 | Py_ssize_t others_length; |
52 | |
|
53 | 0 | others = args; |
54 | 0 | others_length = nargs; |
55 | 0 | return_value = set_update_impl((PySetObject *)so, others, others_length); |
56 | |
|
57 | 0 | return return_value; |
58 | 0 | } |
59 | | |
60 | | PyDoc_STRVAR(set_copy__doc__, |
61 | | "copy($self, /)\n" |
62 | | "--\n" |
63 | | "\n" |
64 | | "Return a shallow copy of a set."); |
65 | | |
66 | | #define SET_COPY_METHODDEF \ |
67 | | {"copy", (PyCFunction)set_copy, METH_NOARGS, set_copy__doc__}, |
68 | | |
69 | | static PyObject * |
70 | | set_copy_impl(PySetObject *so); |
71 | | |
72 | | static PyObject * |
73 | | set_copy(PyObject *so, PyObject *Py_UNUSED(ignored)) |
74 | 27 | { |
75 | 27 | PyObject *return_value = NULL; |
76 | | |
77 | 27 | Py_BEGIN_CRITICAL_SECTION(so); |
78 | 27 | return_value = set_copy_impl((PySetObject *)so); |
79 | 27 | Py_END_CRITICAL_SECTION(); |
80 | | |
81 | 27 | return return_value; |
82 | 27 | } |
83 | | |
84 | | PyDoc_STRVAR(frozenset_copy__doc__, |
85 | | "copy($self, /)\n" |
86 | | "--\n" |
87 | | "\n" |
88 | | "Return a shallow copy of a set."); |
89 | | |
90 | | #define FROZENSET_COPY_METHODDEF \ |
91 | | {"copy", (PyCFunction)frozenset_copy, METH_NOARGS, frozenset_copy__doc__}, |
92 | | |
93 | | static PyObject * |
94 | | frozenset_copy_impl(PySetObject *so); |
95 | | |
96 | | static PyObject * |
97 | | frozenset_copy(PyObject *so, PyObject *Py_UNUSED(ignored)) |
98 | 0 | { |
99 | 0 | PyObject *return_value = NULL; |
100 | |
|
101 | 0 | Py_BEGIN_CRITICAL_SECTION(so); |
102 | 0 | return_value = frozenset_copy_impl((PySetObject *)so); |
103 | 0 | Py_END_CRITICAL_SECTION(); |
104 | |
|
105 | 0 | return return_value; |
106 | 0 | } |
107 | | |
108 | | PyDoc_STRVAR(set_clear__doc__, |
109 | | "clear($self, /)\n" |
110 | | "--\n" |
111 | | "\n" |
112 | | "Remove all elements from this set."); |
113 | | |
114 | | #define SET_CLEAR_METHODDEF \ |
115 | | {"clear", (PyCFunction)set_clear, METH_NOARGS, set_clear__doc__}, |
116 | | |
117 | | static PyObject * |
118 | | set_clear_impl(PySetObject *so); |
119 | | |
120 | | static PyObject * |
121 | | set_clear(PyObject *so, PyObject *Py_UNUSED(ignored)) |
122 | 160 | { |
123 | 160 | PyObject *return_value = NULL; |
124 | | |
125 | 160 | Py_BEGIN_CRITICAL_SECTION(so); |
126 | 160 | return_value = set_clear_impl((PySetObject *)so); |
127 | 160 | Py_END_CRITICAL_SECTION(); |
128 | | |
129 | 160 | return return_value; |
130 | 160 | } |
131 | | |
132 | | PyDoc_STRVAR(set_union__doc__, |
133 | | "union($self, /, *others)\n" |
134 | | "--\n" |
135 | | "\n" |
136 | | "Return a new set with elements from the set and all others."); |
137 | | |
138 | | #define SET_UNION_METHODDEF \ |
139 | | {"union", _PyCFunction_CAST(set_union), METH_FASTCALL, set_union__doc__}, |
140 | | |
141 | | static PyObject * |
142 | | set_union_impl(PySetObject *so, PyObject * const *others, |
143 | | Py_ssize_t others_length); |
144 | | |
145 | | static PyObject * |
146 | | set_union(PyObject *so, PyObject *const *args, Py_ssize_t nargs) |
147 | 2 | { |
148 | 2 | PyObject *return_value = NULL; |
149 | 2 | PyObject * const *others; |
150 | 2 | Py_ssize_t others_length; |
151 | | |
152 | 2 | others = args; |
153 | 2 | others_length = nargs; |
154 | 2 | return_value = set_union_impl((PySetObject *)so, others, others_length); |
155 | | |
156 | 2 | return return_value; |
157 | 2 | } |
158 | | |
159 | | PyDoc_STRVAR(set_intersection_multi__doc__, |
160 | | "intersection($self, /, *others)\n" |
161 | | "--\n" |
162 | | "\n" |
163 | | "Return a new set with elements common to the set and all others."); |
164 | | |
165 | | #define SET_INTERSECTION_MULTI_METHODDEF \ |
166 | | {"intersection", _PyCFunction_CAST(set_intersection_multi), METH_FASTCALL, set_intersection_multi__doc__}, |
167 | | |
168 | | static PyObject * |
169 | | set_intersection_multi_impl(PySetObject *so, PyObject * const *others, |
170 | | Py_ssize_t others_length); |
171 | | |
172 | | static PyObject * |
173 | | set_intersection_multi(PyObject *so, PyObject *const *args, Py_ssize_t nargs) |
174 | 0 | { |
175 | 0 | PyObject *return_value = NULL; |
176 | 0 | PyObject * const *others; |
177 | 0 | Py_ssize_t others_length; |
178 | |
|
179 | 0 | others = args; |
180 | 0 | others_length = nargs; |
181 | 0 | return_value = set_intersection_multi_impl((PySetObject *)so, others, others_length); |
182 | |
|
183 | 0 | return return_value; |
184 | 0 | } |
185 | | |
186 | | PyDoc_STRVAR(set_intersection_update_multi__doc__, |
187 | | "intersection_update($self, /, *others)\n" |
188 | | "--\n" |
189 | | "\n" |
190 | | "Update the set, keeping only elements found in it and all others."); |
191 | | |
192 | | #define SET_INTERSECTION_UPDATE_MULTI_METHODDEF \ |
193 | | {"intersection_update", _PyCFunction_CAST(set_intersection_update_multi), METH_FASTCALL, set_intersection_update_multi__doc__}, |
194 | | |
195 | | static PyObject * |
196 | | set_intersection_update_multi_impl(PySetObject *so, PyObject * const *others, |
197 | | Py_ssize_t others_length); |
198 | | |
199 | | static PyObject * |
200 | | set_intersection_update_multi(PyObject *so, PyObject *const *args, Py_ssize_t nargs) |
201 | 0 | { |
202 | 0 | PyObject *return_value = NULL; |
203 | 0 | PyObject * const *others; |
204 | 0 | Py_ssize_t others_length; |
205 | |
|
206 | 0 | others = args; |
207 | 0 | others_length = nargs; |
208 | 0 | return_value = set_intersection_update_multi_impl((PySetObject *)so, others, others_length); |
209 | |
|
210 | 0 | return return_value; |
211 | 0 | } |
212 | | |
213 | | PyDoc_STRVAR(set_isdisjoint__doc__, |
214 | | "isdisjoint($self, other, /)\n" |
215 | | "--\n" |
216 | | "\n" |
217 | | "Return True if two sets have a null intersection."); |
218 | | |
219 | | #define SET_ISDISJOINT_METHODDEF \ |
220 | | {"isdisjoint", (PyCFunction)set_isdisjoint, METH_O, set_isdisjoint__doc__}, |
221 | | |
222 | | static PyObject * |
223 | | set_isdisjoint_impl(PySetObject *so, PyObject *other); |
224 | | |
225 | | static PyObject * |
226 | | set_isdisjoint(PyObject *so, PyObject *other) |
227 | 15.4k | { |
228 | 15.4k | PyObject *return_value = NULL; |
229 | | |
230 | 15.4k | Py_BEGIN_CRITICAL_SECTION2(so, other); |
231 | 15.4k | return_value = set_isdisjoint_impl((PySetObject *)so, other); |
232 | 15.4k | Py_END_CRITICAL_SECTION2(); |
233 | | |
234 | 15.4k | return return_value; |
235 | 15.4k | } |
236 | | |
237 | | PyDoc_STRVAR(set_difference_update__doc__, |
238 | | "difference_update($self, /, *others)\n" |
239 | | "--\n" |
240 | | "\n" |
241 | | "Update the set, removing elements found in others."); |
242 | | |
243 | | #define SET_DIFFERENCE_UPDATE_METHODDEF \ |
244 | | {"difference_update", _PyCFunction_CAST(set_difference_update), METH_FASTCALL, set_difference_update__doc__}, |
245 | | |
246 | | static PyObject * |
247 | | set_difference_update_impl(PySetObject *so, PyObject * const *others, |
248 | | Py_ssize_t others_length); |
249 | | |
250 | | static PyObject * |
251 | | set_difference_update(PyObject *so, PyObject *const *args, Py_ssize_t nargs) |
252 | 0 | { |
253 | 0 | PyObject *return_value = NULL; |
254 | 0 | PyObject * const *others; |
255 | 0 | Py_ssize_t others_length; |
256 | |
|
257 | 0 | others = args; |
258 | 0 | others_length = nargs; |
259 | 0 | return_value = set_difference_update_impl((PySetObject *)so, others, others_length); |
260 | |
|
261 | 0 | return return_value; |
262 | 0 | } |
263 | | |
264 | | PyDoc_STRVAR(set_difference_multi__doc__, |
265 | | "difference($self, /, *others)\n" |
266 | | "--\n" |
267 | | "\n" |
268 | | "Return a new set with elements in the set that are not in the others."); |
269 | | |
270 | | #define SET_DIFFERENCE_MULTI_METHODDEF \ |
271 | | {"difference", _PyCFunction_CAST(set_difference_multi), METH_FASTCALL, set_difference_multi__doc__}, |
272 | | |
273 | | static PyObject * |
274 | | set_difference_multi_impl(PySetObject *so, PyObject * const *others, |
275 | | Py_ssize_t others_length); |
276 | | |
277 | | static PyObject * |
278 | | set_difference_multi(PyObject *so, PyObject *const *args, Py_ssize_t nargs) |
279 | 0 | { |
280 | 0 | PyObject *return_value = NULL; |
281 | 0 | PyObject * const *others; |
282 | 0 | Py_ssize_t others_length; |
283 | |
|
284 | 0 | others = args; |
285 | 0 | others_length = nargs; |
286 | 0 | return_value = set_difference_multi_impl((PySetObject *)so, others, others_length); |
287 | |
|
288 | 0 | return return_value; |
289 | 0 | } |
290 | | |
291 | | PyDoc_STRVAR(set_symmetric_difference_update__doc__, |
292 | | "symmetric_difference_update($self, other, /)\n" |
293 | | "--\n" |
294 | | "\n" |
295 | | "Update the set, keeping only elements found in either set, but not in both."); |
296 | | |
297 | | #define SET_SYMMETRIC_DIFFERENCE_UPDATE_METHODDEF \ |
298 | | {"symmetric_difference_update", (PyCFunction)set_symmetric_difference_update, METH_O, set_symmetric_difference_update__doc__}, |
299 | | |
300 | | static PyObject * |
301 | | set_symmetric_difference_update_impl(PySetObject *so, PyObject *other); |
302 | | |
303 | | static PyObject * |
304 | | set_symmetric_difference_update(PyObject *so, PyObject *other) |
305 | 0 | { |
306 | 0 | PyObject *return_value = NULL; |
307 | |
|
308 | 0 | return_value = set_symmetric_difference_update_impl((PySetObject *)so, other); |
309 | |
|
310 | 0 | return return_value; |
311 | 0 | } |
312 | | |
313 | | PyDoc_STRVAR(set_symmetric_difference__doc__, |
314 | | "symmetric_difference($self, other, /)\n" |
315 | | "--\n" |
316 | | "\n" |
317 | | "Return a new set with elements in either the set or other but not both."); |
318 | | |
319 | | #define SET_SYMMETRIC_DIFFERENCE_METHODDEF \ |
320 | | {"symmetric_difference", (PyCFunction)set_symmetric_difference, METH_O, set_symmetric_difference__doc__}, |
321 | | |
322 | | static PyObject * |
323 | | set_symmetric_difference_impl(PySetObject *so, PyObject *other); |
324 | | |
325 | | static PyObject * |
326 | | set_symmetric_difference(PyObject *so, PyObject *other) |
327 | 0 | { |
328 | 0 | PyObject *return_value = NULL; |
329 | |
|
330 | 0 | Py_BEGIN_CRITICAL_SECTION2(so, other); |
331 | 0 | return_value = set_symmetric_difference_impl((PySetObject *)so, other); |
332 | 0 | Py_END_CRITICAL_SECTION2(); |
333 | |
|
334 | 0 | return return_value; |
335 | 0 | } |
336 | | |
337 | | PyDoc_STRVAR(set_issubset__doc__, |
338 | | "issubset($self, other, /)\n" |
339 | | "--\n" |
340 | | "\n" |
341 | | "Report whether another set contains this set."); |
342 | | |
343 | | #define SET_ISSUBSET_METHODDEF \ |
344 | | {"issubset", (PyCFunction)set_issubset, METH_O, set_issubset__doc__}, |
345 | | |
346 | | static PyObject * |
347 | | set_issubset_impl(PySetObject *so, PyObject *other); |
348 | | |
349 | | static PyObject * |
350 | | set_issubset(PyObject *so, PyObject *other) |
351 | 50 | { |
352 | 50 | PyObject *return_value = NULL; |
353 | | |
354 | 50 | Py_BEGIN_CRITICAL_SECTION2(so, other); |
355 | 50 | return_value = set_issubset_impl((PySetObject *)so, other); |
356 | 50 | Py_END_CRITICAL_SECTION2(); |
357 | | |
358 | 50 | return return_value; |
359 | 50 | } |
360 | | |
361 | | PyDoc_STRVAR(set_issuperset__doc__, |
362 | | "issuperset($self, other, /)\n" |
363 | | "--\n" |
364 | | "\n" |
365 | | "Report whether this set contains another set."); |
366 | | |
367 | | #define SET_ISSUPERSET_METHODDEF \ |
368 | | {"issuperset", (PyCFunction)set_issuperset, METH_O, set_issuperset__doc__}, |
369 | | |
370 | | static PyObject * |
371 | | set_issuperset_impl(PySetObject *so, PyObject *other); |
372 | | |
373 | | static PyObject * |
374 | | set_issuperset(PyObject *so, PyObject *other) |
375 | 282 | { |
376 | 282 | PyObject *return_value = NULL; |
377 | | |
378 | 282 | Py_BEGIN_CRITICAL_SECTION2(so, other); |
379 | 282 | return_value = set_issuperset_impl((PySetObject *)so, other); |
380 | 282 | Py_END_CRITICAL_SECTION2(); |
381 | | |
382 | 282 | return return_value; |
383 | 282 | } |
384 | | |
385 | | PyDoc_STRVAR(set_add__doc__, |
386 | | "add($self, object, /)\n" |
387 | | "--\n" |
388 | | "\n" |
389 | | "Add an element to a set.\n" |
390 | | "\n" |
391 | | "This has no effect if the element is already present."); |
392 | | |
393 | | #define SET_ADD_METHODDEF \ |
394 | | {"add", (PyCFunction)set_add, METH_O, set_add__doc__}, |
395 | | |
396 | | static PyObject * |
397 | | set_add_impl(PySetObject *so, PyObject *key); |
398 | | |
399 | | static PyObject * |
400 | | set_add(PyObject *so, PyObject *key) |
401 | 568k | { |
402 | 568k | PyObject *return_value = NULL; |
403 | | |
404 | 568k | Py_BEGIN_CRITICAL_SECTION(so); |
405 | 568k | return_value = set_add_impl((PySetObject *)so, key); |
406 | 568k | Py_END_CRITICAL_SECTION(); |
407 | | |
408 | 568k | return return_value; |
409 | 568k | } |
410 | | |
411 | | PyDoc_STRVAR(set___contains____doc__, |
412 | | "__contains__($self, object, /)\n" |
413 | | "--\n" |
414 | | "\n" |
415 | | "x.__contains__(y) <==> y in x."); |
416 | | |
417 | | #define SET___CONTAINS___METHODDEF \ |
418 | | {"__contains__", (PyCFunction)set___contains__, METH_O|METH_COEXIST, set___contains____doc__}, |
419 | | |
420 | | static PyObject * |
421 | | set___contains___impl(PySetObject *so, PyObject *key); |
422 | | |
423 | | static PyObject * |
424 | | set___contains__(PyObject *so, PyObject *key) |
425 | 16.5M | { |
426 | 16.5M | PyObject *return_value = NULL; |
427 | | |
428 | 16.5M | Py_BEGIN_CRITICAL_SECTION(so); |
429 | 16.5M | return_value = set___contains___impl((PySetObject *)so, key); |
430 | 16.5M | Py_END_CRITICAL_SECTION(); |
431 | | |
432 | 16.5M | return return_value; |
433 | 16.5M | } |
434 | | |
435 | | PyDoc_STRVAR(frozenset___contains____doc__, |
436 | | "__contains__($self, object, /)\n" |
437 | | "--\n" |
438 | | "\n" |
439 | | "x.__contains__(y) <==> y in x."); |
440 | | |
441 | | #define FROZENSET___CONTAINS___METHODDEF \ |
442 | | {"__contains__", (PyCFunction)frozenset___contains__, METH_O|METH_COEXIST, frozenset___contains____doc__}, |
443 | | |
444 | | static PyObject * |
445 | | frozenset___contains___impl(PySetObject *so, PyObject *key); |
446 | | |
447 | | static PyObject * |
448 | | frozenset___contains__(PyObject *so, PyObject *key) |
449 | 221 | { |
450 | 221 | PyObject *return_value = NULL; |
451 | | |
452 | 221 | return_value = frozenset___contains___impl((PySetObject *)so, key); |
453 | | |
454 | 221 | return return_value; |
455 | 221 | } |
456 | | |
457 | | PyDoc_STRVAR(set_remove__doc__, |
458 | | "remove($self, object, /)\n" |
459 | | "--\n" |
460 | | "\n" |
461 | | "Remove an element from a set; it must be a member.\n" |
462 | | "\n" |
463 | | "If the element is not a member, raise a KeyError."); |
464 | | |
465 | | #define SET_REMOVE_METHODDEF \ |
466 | | {"remove", (PyCFunction)set_remove, METH_O, set_remove__doc__}, |
467 | | |
468 | | static PyObject * |
469 | | set_remove_impl(PySetObject *so, PyObject *key); |
470 | | |
471 | | static PyObject * |
472 | | set_remove(PyObject *so, PyObject *key) |
473 | 0 | { |
474 | 0 | PyObject *return_value = NULL; |
475 | |
|
476 | 0 | Py_BEGIN_CRITICAL_SECTION(so); |
477 | 0 | return_value = set_remove_impl((PySetObject *)so, key); |
478 | 0 | Py_END_CRITICAL_SECTION(); |
479 | |
|
480 | 0 | return return_value; |
481 | 0 | } |
482 | | |
483 | | PyDoc_STRVAR(set_discard__doc__, |
484 | | "discard($self, object, /)\n" |
485 | | "--\n" |
486 | | "\n" |
487 | | "Remove an element from a set if it is a member.\n" |
488 | | "\n" |
489 | | "Unlike set.remove(), the discard() method does not raise\n" |
490 | | "an exception when an element is missing from the set."); |
491 | | |
492 | | #define SET_DISCARD_METHODDEF \ |
493 | | {"discard", (PyCFunction)set_discard, METH_O, set_discard__doc__}, |
494 | | |
495 | | static PyObject * |
496 | | set_discard_impl(PySetObject *so, PyObject *key); |
497 | | |
498 | | static PyObject * |
499 | | set_discard(PyObject *so, PyObject *key) |
500 | 0 | { |
501 | 0 | PyObject *return_value = NULL; |
502 | |
|
503 | 0 | Py_BEGIN_CRITICAL_SECTION(so); |
504 | 0 | return_value = set_discard_impl((PySetObject *)so, key); |
505 | 0 | Py_END_CRITICAL_SECTION(); |
506 | |
|
507 | 0 | return return_value; |
508 | 0 | } |
509 | | |
510 | | PyDoc_STRVAR(set___reduce____doc__, |
511 | | "__reduce__($self, /)\n" |
512 | | "--\n" |
513 | | "\n" |
514 | | "Return state information for pickling."); |
515 | | |
516 | | #define SET___REDUCE___METHODDEF \ |
517 | | {"__reduce__", (PyCFunction)set___reduce__, METH_NOARGS, set___reduce____doc__}, |
518 | | |
519 | | static PyObject * |
520 | | set___reduce___impl(PySetObject *so); |
521 | | |
522 | | static PyObject * |
523 | | set___reduce__(PyObject *so, PyObject *Py_UNUSED(ignored)) |
524 | 0 | { |
525 | 0 | PyObject *return_value = NULL; |
526 | |
|
527 | 0 | Py_BEGIN_CRITICAL_SECTION(so); |
528 | 0 | return_value = set___reduce___impl((PySetObject *)so); |
529 | 0 | Py_END_CRITICAL_SECTION(); |
530 | |
|
531 | 0 | return return_value; |
532 | 0 | } |
533 | | |
534 | | PyDoc_STRVAR(set___sizeof____doc__, |
535 | | "__sizeof__($self, /)\n" |
536 | | "--\n" |
537 | | "\n" |
538 | | "S.__sizeof__() -> size of S in memory, in bytes."); |
539 | | |
540 | | #define SET___SIZEOF___METHODDEF \ |
541 | | {"__sizeof__", (PyCFunction)set___sizeof__, METH_NOARGS, set___sizeof____doc__}, |
542 | | |
543 | | static PyObject * |
544 | | set___sizeof___impl(PySetObject *so); |
545 | | |
546 | | static PyObject * |
547 | | set___sizeof__(PyObject *so, PyObject *Py_UNUSED(ignored)) |
548 | 0 | { |
549 | 0 | PyObject *return_value = NULL; |
550 | |
|
551 | 0 | Py_BEGIN_CRITICAL_SECTION(so); |
552 | 0 | return_value = set___sizeof___impl((PySetObject *)so); |
553 | 0 | Py_END_CRITICAL_SECTION(); |
554 | |
|
555 | 0 | return return_value; |
556 | 0 | } |
557 | | /*[clinic end generated code: output=7f7fe845ca165078 input=a9049054013a1b77]*/ |