Lines Matching refs:so
56 set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash) in set_lookkey() argument
61 size_t mask = so->mask; in set_lookkey()
67 entry = &so->table[i]; in set_lookkey()
81 table = so->table; in set_lookkey()
87 if (table != so->table || entry->key != startkey) in set_lookkey()
88 return set_lookkey(so, key, hash); in set_lookkey()
91 mask = so->mask; in set_lookkey()
103 set_add_entry(PySetObject *so, PyObject *key, Py_hash_t hash) in set_add_entry() argument
120 mask = so->mask; in set_add_entry()
126 entry = &so->table[i]; in set_add_entry()
140 table = so->table; in set_add_entry()
148 if (table != so->table || entry->key != startkey) in set_add_entry()
150 mask = so->mask; in set_add_entry()
165 so->used++; in set_add_entry()
171 so->fill++; in set_add_entry()
172 so->used++; in set_add_entry()
175 if ((size_t)so->fill*5 < mask*3) in set_add_entry()
177 return set_table_resize(so, so->used>50000 ? so->used*2 : so->used*4); in set_add_entry()
232 set_table_resize(PySetObject *so, Py_ssize_t minused) in set_table_resize() argument
235 Py_ssize_t oldmask = so->mask; in set_table_resize()
250 oldtable = so->table; in set_table_resize()
252 is_oldtable_malloced = oldtable != so->smalltable; in set_table_resize()
256 newtable = so->smalltable; in set_table_resize()
258 if (so->fill == so->used) { in set_table_resize()
268 assert(so->fill > so->used); in set_table_resize()
284 so->mask = newsize - 1; in set_table_resize()
285 so->table = newtable; in set_table_resize()
289 newmask = (size_t)so->mask; in set_table_resize()
290 if (so->fill == so->used) { in set_table_resize()
297 so->fill = so->used; in set_table_resize()
311 set_contains_entry(PySetObject *so, PyObject *key, Py_hash_t hash) in set_contains_entry() argument
315 entry = set_lookkey(so, key, hash); in set_contains_entry()
325 set_discard_entry(PySetObject *so, PyObject *key, Py_hash_t hash) in set_discard_entry() argument
330 entry = set_lookkey(so, key, hash); in set_discard_entry()
338 so->used--; in set_discard_entry()
344 set_add_key(PySetObject *so, PyObject *key) in set_add_key() argument
354 return set_add_entry(so, key, hash); in set_add_key()
358 set_contains_key(PySetObject *so, PyObject *key) in set_contains_key() argument
368 return set_contains_entry(so, key, hash); in set_contains_key()
372 set_discard_key(PySetObject *so, PyObject *key) in set_discard_key() argument
382 return set_discard_entry(so, key, hash); in set_discard_key()
386 set_empty_to_minsize(PySetObject *so) in set_empty_to_minsize() argument
388 memset(so->smalltable, 0, sizeof(so->smalltable)); in set_empty_to_minsize()
389 so->fill = 0; in set_empty_to_minsize()
390 so->used = 0; in set_empty_to_minsize()
391 so->mask = PySet_MINSIZE - 1; in set_empty_to_minsize()
392 so->table = so->smalltable; in set_empty_to_minsize()
393 so->hash = -1; in set_empty_to_minsize()
397 set_clear_internal(PySetObject *so) in set_clear_internal() argument
400 setentry *table = so->table; in set_clear_internal()
401 Py_ssize_t fill = so->fill; in set_clear_internal()
402 Py_ssize_t used = so->used; in set_clear_internal()
403 int table_is_malloced = table != so->smalltable; in set_clear_internal()
406 assert (PyAnySet_Check(so)); in set_clear_internal()
416 set_empty_to_minsize(so); in set_clear_internal()
425 set_empty_to_minsize(so); in set_clear_internal()
459 set_next(PySetObject *so, Py_ssize_t *pos_ptr, setentry **entry_ptr) in set_next() argument
465 assert (PyAnySet_Check(so)); in set_next()
468 mask = so->mask; in set_next()
469 entry = &so->table[i]; in set_next()
483 set_dealloc(PySetObject *so) in set_dealloc() argument
486 Py_ssize_t used = so->used; in set_dealloc()
489 PyObject_GC_UnTrack(so); in set_dealloc()
490 Py_TRASHCAN_BEGIN(so, set_dealloc) in set_dealloc()
491 if (so->weakreflist != NULL) in set_dealloc()
492 PyObject_ClearWeakRefs((PyObject *) so); in set_dealloc()
494 for (entry = so->table; used > 0; entry++) { in set_dealloc()
500 if (so->table != so->smalltable) in set_dealloc()
501 PyMem_Free(so->table); in set_dealloc()
502 Py_TYPE(so)->tp_free(so); in set_dealloc()
507 set_repr(PySetObject *so) in set_repr() argument
510 int status = Py_ReprEnter((PyObject*)so); in set_repr()
515 return PyUnicode_FromFormat("%s(...)", Py_TYPE(so)->tp_name); in set_repr()
519 if (!so->used) { in set_repr()
520 Py_ReprLeave((PyObject*)so); in set_repr()
521 return PyUnicode_FromFormat("%s()", Py_TYPE(so)->tp_name); in set_repr()
524 keys = PySequence_List((PyObject *)so); in set_repr()
539 if (!PySet_CheckExact(so)) in set_repr()
541 Py_TYPE(so)->tp_name, in set_repr()
547 Py_ReprLeave((PyObject*)so); in set_repr()
552 set_len(PyObject *so) in set_len() argument
554 return ((PySetObject *)so)->used; in set_len()
558 set_merge(PySetObject *so, PyObject *otherset) in set_merge() argument
566 assert (PyAnySet_Check(so)); in set_merge()
570 if (other == so || other->used == 0) in set_merge()
577 if ((so->fill + other->used)*5 >= so->mask*3) { in set_merge()
578 if (set_table_resize(so, (so->used + other->used)*2) != 0) in set_merge()
581 so_entry = so->table; in set_merge()
586 if (so->fill == 0 && so->mask == other->mask && other->fill == other->used) { in set_merge()
596 so->fill = other->fill; in set_merge()
597 so->used = other->used; in set_merge()
602 if (so->fill == 0) { in set_merge()
603 setentry *newtable = so->table; in set_merge()
604 size_t newmask = (size_t)so->mask; in set_merge()
605 so->fill = other->used; in set_merge()
606 so->used = other->used; in set_merge()
622 if (set_add_entry(so, key, other_entry->hash)) in set_merge()
630 set_pop(PySetObject *so, PyObject *Py_UNUSED(ignored)) in set_pop() argument
633 setentry *entry = so->table + (so->finger & so->mask); in set_pop()
634 setentry *limit = so->table + so->mask; in set_pop()
637 if (so->used == 0) { in set_pop()
644 entry = so->table; in set_pop()
649 so->used--; in set_pop()
650 so->finger = entry - so->table + 1; /* next place to start */ in set_pop()
658 set_traverse(PySetObject *so, visitproc visit, void *arg) in set_traverse() argument
663 while (set_next(so, &pos, &entry)) in set_traverse()
688 PySetObject *so = (PySetObject *)self; in frozenset_hash() local
692 if (so->hash != -1) in frozenset_hash()
693 return so->hash; in frozenset_hash()
705 for (entry = so->table; entry <= &so->table[so->mask]; entry++) in frozenset_hash()
709 if ((so->mask + 1 - so->fill) & 1) in frozenset_hash()
713 if ((so->fill - so->used) & 1) in frozenset_hash()
727 so->hash = hash; in frozenset_hash()
800 PySetObject *so = si->si_set; in setiter_iternext() local
802 if (so == NULL) in setiter_iternext()
804 assert (PyAnySet_Check(so)); in setiter_iternext()
806 if (si->si_used != so->used) { in setiter_iternext()
815 entry = so->table; in setiter_iternext()
816 mask = so->mask; in setiter_iternext()
829 Py_DECREF(so); in setiter_iternext()
867 set_iter(PySetObject *so) in set_iter() argument
872 Py_INCREF(so); in set_iter()
873 si->si_set = so; in set_iter()
874 si->si_used = so->used; in set_iter()
876 si->len = so->used; in set_iter()
882 set_update_internal(PySetObject *so, PyObject *other) in set_update_internal() argument
887 return set_merge(so, other); in set_update_internal()
901 if ((so->fill + dictsize)*5 >= so->mask*3) { in set_update_internal()
902 if (set_table_resize(so, (so->used + dictsize)*2) != 0) in set_update_internal()
906 if (set_add_entry(so, key, hash)) in set_update_internal()
917 if (set_add_key(so, key)) { in set_update_internal()
931 set_update(PySetObject *so, PyObject *args) in set_update() argument
937 if (set_update_internal(so, other)) in set_update()
956 PySetObject *so; in make_new_set() local
958 so = (PySetObject *)type->tp_alloc(type, 0); in make_new_set()
959 if (so == NULL) in make_new_set()
962 so->fill = 0; in make_new_set()
963 so->used = 0; in make_new_set()
964 so->mask = PySet_MINSIZE - 1; in make_new_set()
965 so->table = so->smalltable; in make_new_set()
966 so->hash = -1; in make_new_set()
967 so->finger = 0; in make_new_set()
968 so->weakreflist = NULL; in make_new_set()
971 if (set_update_internal(so, iterable)) { in make_new_set()
972 Py_DECREF(so); in make_new_set()
977 return (PyObject *)so; in make_new_set()
1093 set_copy(PySetObject *so, PyObject *Py_UNUSED(ignored)) in set_copy() argument
1095 return make_new_set_basetype(Py_TYPE(so), (PyObject *)so); in set_copy()
1099 frozenset_copy(PySetObject *so, PyObject *Py_UNUSED(ignored)) in frozenset_copy() argument
1101 if (PyFrozenSet_CheckExact(so)) { in frozenset_copy()
1102 Py_INCREF(so); in frozenset_copy()
1103 return (PyObject *)so; in frozenset_copy()
1105 return set_copy(so, NULL); in frozenset_copy()
1111 set_clear(PySetObject *so, PyObject *Py_UNUSED(ignored)) in set_clear() argument
1113 set_clear_internal(so); in set_clear()
1120 set_union(PySetObject *so, PyObject *args) in set_union() argument
1126 result = (PySetObject *)set_copy(so, NULL); in set_union()
1132 if ((PyObject *)so == other) in set_union()
1148 set_or(PySetObject *so, PyObject *other) in set_or() argument
1152 if (!PyAnySet_Check(so) || !PyAnySet_Check(other)) in set_or()
1155 result = (PySetObject *)set_copy(so, NULL); in set_or()
1158 if ((PyObject *)so == other) in set_or()
1168 set_ior(PySetObject *so, PyObject *other) in set_ior() argument
1173 if (set_update_internal(so, other)) in set_ior()
1175 Py_INCREF(so); in set_ior()
1176 return (PyObject *)so; in set_ior()
1180 set_intersection(PySetObject *so, PyObject *other) in set_intersection() argument
1187 if ((PyObject *)so == other) in set_intersection()
1188 return set_copy(so, NULL); in set_intersection()
1190 result = (PySetObject *)make_new_set_basetype(Py_TYPE(so), NULL); in set_intersection()
1198 if (PySet_GET_SIZE(other) > PySet_GET_SIZE(so)) { in set_intersection()
1199 tmp = (PyObject *)so; in set_intersection()
1200 so = (PySetObject *)other; in set_intersection()
1207 rv = set_contains_entry(so, key, hash); in set_intersection()
1232 rv = set_contains_entry(so, key, hash); in set_intersection()
1255 set_intersection_multi(PySetObject *so, PyObject *args) in set_intersection_multi() argument
1258 PyObject *result = (PyObject *)so; in set_intersection_multi()
1261 return set_copy(so, NULL); in set_intersection_multi()
1263 Py_INCREF(so); in set_intersection_multi()
1283 set_intersection_update(PySetObject *so, PyObject *other) in set_intersection_update() argument
1287 tmp = set_intersection(so, other); in set_intersection_update()
1290 set_swap_bodies(so, (PySetObject *)tmp); in set_intersection_update()
1296 set_intersection_update_multi(PySetObject *so, PyObject *args) in set_intersection_update_multi() argument
1300 tmp = set_intersection_multi(so, args); in set_intersection_update_multi()
1303 set_swap_bodies(so, (PySetObject *)tmp); in set_intersection_update_multi()
1312 set_and(PySetObject *so, PyObject *other) in set_and() argument
1314 if (!PyAnySet_Check(so) || !PyAnySet_Check(other)) in set_and()
1316 return set_intersection(so, other); in set_and()
1320 set_iand(PySetObject *so, PyObject *other) in set_iand() argument
1326 result = set_intersection_update(so, other); in set_iand()
1330 Py_INCREF(so); in set_iand()
1331 return (PyObject *)so; in set_iand()
1335 set_isdisjoint(PySetObject *so, PyObject *other) in set_isdisjoint() argument
1340 if ((PyObject *)so == other) { in set_isdisjoint()
1341 if (PySet_GET_SIZE(so) == 0) in set_isdisjoint()
1351 if (PySet_GET_SIZE(other) > PySet_GET_SIZE(so)) { in set_isdisjoint()
1352 tmp = (PyObject *)so; in set_isdisjoint()
1353 so = (PySetObject *)other; in set_isdisjoint()
1357 rv = set_contains_entry(so, entry->key, entry->hash); in set_isdisjoint()
1378 rv = set_contains_entry(so, key, hash); in set_isdisjoint()
1399 set_difference_update_internal(PySetObject *so, PyObject *other) in set_difference_update_internal() argument
1401 if ((PyObject *)so == other) in set_difference_update_internal()
1402 return set_clear_internal(so); in set_difference_update_internal()
1412 if ((PySet_GET_SIZE(other) >> 3) > PySet_GET_SIZE(so)) { in set_difference_update_internal()
1413 other = set_intersection(so, other); in set_difference_update_internal()
1421 if (set_discard_entry(so, entry->key, entry->hash) < 0) { in set_difference_update_internal()
1434 if (set_discard_key(so, key) < 0) { in set_difference_update_internal()
1446 if ((size_t)(so->fill - so->used) <= (size_t)so->mask / 4) in set_difference_update_internal()
1448 return set_table_resize(so, so->used>50000 ? so->used*2 : so->used*4); in set_difference_update_internal()
1452 set_difference_update(PySetObject *so, PyObject *args) in set_difference_update() argument
1458 if (set_difference_update_internal(so, other)) in set_difference_update()
1468 set_copy_and_difference(PySetObject *so, PyObject *other) in set_copy_and_difference() argument
1472 result = set_copy(so, NULL); in set_copy_and_difference()
1482 set_difference(PySetObject *so, PyObject *other) in set_difference() argument
1498 return set_copy_and_difference(so, other); in set_difference()
1503 if ((PySet_GET_SIZE(so) >> 2) > other_size) { in set_difference()
1504 return set_copy_and_difference(so, other); in set_difference()
1507 result = make_new_set_basetype(Py_TYPE(so), NULL); in set_difference()
1512 while (set_next(so, &pos, &entry)) { in set_difference()
1531 while (set_next(so, &pos, &entry)) { in set_difference()
1550 set_difference_multi(PySetObject *so, PyObject *args) in set_difference_multi() argument
1556 return set_copy(so, NULL); in set_difference_multi()
1559 result = set_difference(so, other); in set_difference_multi()
1578 set_sub(PySetObject *so, PyObject *other) in set_sub() argument
1580 if (!PyAnySet_Check(so) || !PyAnySet_Check(other)) in set_sub()
1582 return set_difference(so, other); in set_sub()
1586 set_isub(PySetObject *so, PyObject *other) in set_isub() argument
1590 if (set_difference_update_internal(so, other)) in set_isub()
1592 Py_INCREF(so); in set_isub()
1593 return (PyObject *)so; in set_isub()
1597 set_symmetric_difference_update(PySetObject *so, PyObject *other) in set_symmetric_difference_update() argument
1606 if ((PyObject *)so == other) in set_symmetric_difference_update()
1607 return set_clear(so, NULL); in set_symmetric_difference_update()
1613 rv = set_discard_entry(so, key, hash); in set_symmetric_difference_update()
1619 if (set_add_entry(so, key, hash)) { in set_symmetric_difference_update()
1633 otherset = (PySetObject *)make_new_set_basetype(Py_TYPE(so), other); in set_symmetric_difference_update()
1641 rv = set_discard_entry(so, key, hash); in set_symmetric_difference_update()
1647 if (set_add_entry(so, key, hash)) { in set_symmetric_difference_update()
1661 set_symmetric_difference(PySetObject *so, PyObject *other) in set_symmetric_difference() argument
1666 otherset = (PySetObject *)make_new_set_basetype(Py_TYPE(so), other); in set_symmetric_difference()
1669 rv = set_symmetric_difference_update(otherset, (PyObject *)so); in set_symmetric_difference()
1684 set_xor(PySetObject *so, PyObject *other) in set_xor() argument
1686 if (!PyAnySet_Check(so) || !PyAnySet_Check(other)) in set_xor()
1688 return set_symmetric_difference(so, other); in set_xor()
1692 set_ixor(PySetObject *so, PyObject *other) in set_ixor() argument
1698 result = set_symmetric_difference_update(so, other); in set_ixor()
1702 Py_INCREF(so); in set_ixor()
1703 return (PyObject *)so; in set_ixor()
1707 set_issubset(PySetObject *so, PyObject *other) in set_issubset() argument
1718 result = set_issubset(so, tmp); in set_issubset()
1722 if (PySet_GET_SIZE(so) > PySet_GET_SIZE(other)) in set_issubset()
1725 while (set_next(so, &pos, &entry)) { in set_issubset()
1738 set_issuperset(PySetObject *so, PyObject *other) in set_issuperset() argument
1746 result = set_issuperset(so, tmp); in set_issuperset()
1750 return set_issubset((PySetObject *)other, (PyObject *)so); in set_issuperset()
1799 set_add(PySetObject *so, PyObject *key) in set_add() argument
1801 if (set_add_key(so, key)) in set_add()
1812 set_contains(PySetObject *so, PyObject *key) in set_contains() argument
1817 rv = set_contains_key(so, key); in set_contains()
1825 rv = set_contains_key(so, tmpkey); in set_contains()
1832 set_direct_contains(PySetObject *so, PyObject *key) in set_direct_contains() argument
1836 result = set_contains(so, key); in set_direct_contains()
1845 set_remove(PySetObject *so, PyObject *key) in set_remove() argument
1850 rv = set_discard_key(so, key); in set_remove()
1858 rv = set_discard_key(so, tmpkey); in set_remove()
1877 set_discard(PySetObject *so, PyObject *key) in set_discard() argument
1882 rv = set_discard_key(so, key); in set_discard()
1890 rv = set_discard_key(so, tmpkey); in set_discard()
1904 set_reduce(PySetObject *so, PyObject *Py_UNUSED(ignored)) in set_reduce() argument
1909 keys = PySequence_List((PyObject *)so); in set_reduce()
1915 if (_PyObject_LookupAttrId((PyObject *)so, &PyId___dict__, &dict) < 0) { in set_reduce()
1922 result = PyTuple_Pack(3, Py_TYPE(so), args, dict); in set_reduce()
1931 set_sizeof(PySetObject *so, PyObject *Py_UNUSED(ignored)) in set_sizeof() argument
1935 res = _PyObject_SIZE(Py_TYPE(so)); in set_sizeof()
1936 if (so->table != so->smalltable) in set_sizeof()
1937 res = res + (so->mask + 1) * sizeof(setentry); in set_sizeof()
1995 static PyObject *test_c_api(PySetObject *so, PyObject *Py_UNUSED(ignored));
2353 test_c_api(PySetObject *so, PyObject *Py_UNUSED(ignored)) in test_c_api() argument
2359 PyObject *ob = (PyObject *)so; in test_c_api()
2372 set_clear_internal(so); in test_c_api()
2373 if (set_update_internal(so, str)) { in test_c_api()