• Home
  • Raw
  • Download

Lines Matching full: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
119 mask = so->mask; in set_add_entry()
124 entry = &so->table[i]; in set_add_entry()
138 table = so->table; in set_add_entry()
146 if (table != so->table || entry->key != startkey) in set_add_entry()
148 mask = so->mask; in set_add_entry()
157 so->fill++; in set_add_entry()
158 so->used++; in set_add_entry()
161 if ((size_t)so->fill*5 < mask*3) in set_add_entry()
163 return set_table_resize(so, so->used>50000 ? so->used*2 : so->used*4); in set_add_entry()
218 set_table_resize(PySetObject *so, Py_ssize_t minused) in set_table_resize() argument
221 Py_ssize_t oldmask = so->mask; in set_table_resize()
236 oldtable = so->table; in set_table_resize()
238 is_oldtable_malloced = oldtable != so->smalltable; in set_table_resize()
242 newtable = so->smalltable; in set_table_resize()
244 if (so->fill == so->used) { in set_table_resize()
245 /* No dummies, so no point doing anything. */ in set_table_resize()
254 assert(so->fill > so->used); in set_table_resize()
270 so->mask = newsize - 1; in set_table_resize()
271 so->table = newtable; in set_table_resize()
275 newmask = (size_t)so->mask; in set_table_resize()
276 if (so->fill == so->used) { in set_table_resize()
283 so->fill = so->used; in set_table_resize()
297 set_contains_entry(PySetObject *so, PyObject *key, Py_hash_t hash) in set_contains_entry() argument
301 entry = set_lookkey(so, key, hash); in set_contains_entry()
311 set_discard_entry(PySetObject *so, PyObject *key, Py_hash_t hash) in set_discard_entry() argument
316 entry = set_lookkey(so, key, hash); in set_discard_entry()
324 so->used--; in set_discard_entry()
330 set_add_key(PySetObject *so, PyObject *key) in set_add_key() argument
340 return set_add_entry(so, key, hash); in set_add_key()
344 set_contains_key(PySetObject *so, PyObject *key) in set_contains_key() argument
354 return set_contains_entry(so, key, hash); in set_contains_key()
358 set_discard_key(PySetObject *so, PyObject *key) in set_discard_key() argument
368 return set_discard_entry(so, key, hash); in set_discard_key()
372 set_empty_to_minsize(PySetObject *so) in set_empty_to_minsize() argument
374 memset(so->smalltable, 0, sizeof(so->smalltable)); in set_empty_to_minsize()
375 so->fill = 0; in set_empty_to_minsize()
376 so->used = 0; in set_empty_to_minsize()
377 so->mask = PySet_MINSIZE - 1; in set_empty_to_minsize()
378 so->table = so->smalltable; in set_empty_to_minsize()
379 so->hash = -1; in set_empty_to_minsize()
383 set_clear_internal(PySetObject *so) in set_clear_internal() argument
386 setentry *table = so->table; in set_clear_internal()
387 Py_ssize_t fill = so->fill; in set_clear_internal()
388 Py_ssize_t used = so->used; in set_clear_internal()
389 int table_is_malloced = table != so->smalltable; in set_clear_internal()
392 assert (PyAnySet_Check(so)); in set_clear_internal()
398 * clearing the slots, and never refer to anything via so->ref while in set_clear_internal()
402 set_empty_to_minsize(so); in set_clear_internal()
411 set_empty_to_minsize(so); in set_clear_internal()
417 * has unique access to it, so decref side-effects can't alter it. in set_clear_internal()
432 * Iterate over a set table. Use like so:
445 set_next(PySetObject *so, Py_ssize_t *pos_ptr, setentry **entry_ptr) in set_next() argument
451 assert (PyAnySet_Check(so)); in set_next()
454 mask = so->mask; in set_next()
455 entry = &so->table[i]; in set_next()
469 set_dealloc(PySetObject *so) in set_dealloc() argument
472 Py_ssize_t used = so->used; in set_dealloc()
475 PyObject_GC_UnTrack(so); in set_dealloc()
476 Py_TRASHCAN_BEGIN(so, set_dealloc) in set_dealloc()
477 if (so->weakreflist != NULL) in set_dealloc()
478 PyObject_ClearWeakRefs((PyObject *) so); in set_dealloc()
480 for (entry = so->table; used > 0; entry++) { in set_dealloc()
486 if (so->table != so->smalltable) in set_dealloc()
487 PyMem_DEL(so->table); in set_dealloc()
488 Py_TYPE(so)->tp_free(so); in set_dealloc()
493 set_repr(PySetObject *so) in set_repr() argument
496 int status = Py_ReprEnter((PyObject*)so); in set_repr()
501 return PyUnicode_FromFormat("%s(...)", Py_TYPE(so)->tp_name); in set_repr()
505 if (!so->used) { in set_repr()
506 Py_ReprLeave((PyObject*)so); in set_repr()
507 return PyUnicode_FromFormat("%s()", Py_TYPE(so)->tp_name); in set_repr()
510 keys = PySequence_List((PyObject *)so); in set_repr()
525 if (!Py_IS_TYPE(so, &PySet_Type)) in set_repr()
527 Py_TYPE(so)->tp_name, in set_repr()
533 Py_ReprLeave((PyObject*)so); in set_repr()
538 set_len(PyObject *so) in set_len() argument
540 return ((PySetObject *)so)->used; in set_len()
544 set_merge(PySetObject *so, PyObject *otherset) in set_merge() argument
552 assert (PyAnySet_Check(so)); in set_merge()
556 if (other == so || other->used == 0) in set_merge()
563 if ((so->fill + other->used)*5 >= so->mask*3) { in set_merge()
564 if (set_table_resize(so, (so->used + other->used)*2) != 0) in set_merge()
567 so_entry = so->table; in set_merge()
572 if (so->fill == 0 && so->mask == other->mask && other->fill == other->used) { in set_merge()
582 so->fill = other->fill; in set_merge()
583 so->used = other->used; in set_merge()
588 if (so->fill == 0) { in set_merge()
589 setentry *newtable = so->table; in set_merge()
590 size_t newmask = (size_t)so->mask; in set_merge()
591 so->fill = other->used; in set_merge()
592 so->used = other->used; in set_merge()
603 /* We can't assure there are no duplicates, so do normal insertions */ in set_merge()
608 if (set_add_entry(so, key, other_entry->hash)) in set_merge()
616 set_pop(PySetObject *so, PyObject *Py_UNUSED(ignored)) in set_pop() argument
619 setentry *entry = so->table + (so->finger & so->mask); in set_pop()
620 setentry *limit = so->table + so->mask; in set_pop()
623 if (so->used == 0) { in set_pop()
630 entry = so->table; in set_pop()
635 so->used--; in set_pop()
636 so->finger = entry - so->table + 1; /* next place to start */ in set_pop()
644 set_traverse(PySetObject *so, visitproc visit, void *arg) in set_traverse() argument
649 while (set_next(so, &pos, &entry)) in set_traverse()
656 small number of elements with nearby hashes so that many distinct
674 PySetObject *so = (PySetObject *)self; in frozenset_hash() local
678 if (so->hash != -1) in frozenset_hash()
679 return so->hash; in frozenset_hash()
685 subtract out their effect afterwards so that the final hash in frozenset_hash()
691 for (entry = so->table; entry <= &so->table[so->mask]; entry++) in frozenset_hash()
695 if ((so->mask + 1 - so->fill) & 1) in frozenset_hash()
699 if ((so->fill - so->used) & 1) in frozenset_hash()
713 so->hash = hash; in frozenset_hash()
786 PySetObject *so = si->si_set; in setiter_iternext() local
788 if (so == NULL) in setiter_iternext()
790 assert (PyAnySet_Check(so)); in setiter_iternext()
792 if (si->si_used != so->used) { in setiter_iternext()
801 entry = so->table; in setiter_iternext()
802 mask = so->mask; in setiter_iternext()
815 Py_DECREF(so); in setiter_iternext()
853 set_iter(PySetObject *so) in set_iter() argument
858 Py_INCREF(so); in set_iter()
859 si->si_set = so; in set_iter()
860 si->si_used = so->used; in set_iter()
862 si->len = so->used; in set_iter()
868 set_update_internal(PySetObject *so, PyObject *other) in set_update_internal() argument
873 return set_merge(so, other); in set_update_internal()
887 if ((so->fill + dictsize)*5 >= so->mask*3) { in set_update_internal()
888 if (set_table_resize(so, (so->used + dictsize)*2) != 0) in set_update_internal()
892 if (set_add_entry(so, key, hash)) in set_update_internal()
903 if (set_add_key(so, key)) { in set_update_internal()
917 set_update(PySetObject *so, PyObject *args) in set_update() argument
923 if (set_update_internal(so, other)) in set_update()
934 set object 64 byte aligned so that most of the fields
942 PySetObject *so; in make_new_set() local
944 so = (PySetObject *)type->tp_alloc(type, 0); in make_new_set()
945 if (so == NULL) in make_new_set()
948 so->fill = 0; in make_new_set()
949 so->used = 0; in make_new_set()
950 so->mask = PySet_MINSIZE - 1; in make_new_set()
951 so->table = so->smalltable; in make_new_set()
952 so->hash = -1; in make_new_set()
953 so->finger = 0; in make_new_set()
954 so->weakreflist = NULL; in make_new_set()
957 if (set_update_internal(so, iterable)) { in make_new_set()
958 Py_DECREF(so); in make_new_set()
963 return (PyObject *)so; in make_new_set()
1096 set_copy(PySetObject *so, PyObject *Py_UNUSED(ignored)) in set_copy() argument
1098 return make_new_set_basetype(Py_TYPE(so), (PyObject *)so); in set_copy()
1102 frozenset_copy(PySetObject *so, PyObject *Py_UNUSED(ignored)) in frozenset_copy() argument
1104 if (PyFrozenSet_CheckExact(so)) { in frozenset_copy()
1105 Py_INCREF(so); in frozenset_copy()
1106 return (PyObject *)so; in frozenset_copy()
1108 return set_copy(so, NULL); in frozenset_copy()
1114 set_clear(PySetObject *so, PyObject *Py_UNUSED(ignored)) in set_clear() argument
1116 set_clear_internal(so); in set_clear()
1123 set_union(PySetObject *so, PyObject *args) in set_union() argument
1129 result = (PySetObject *)set_copy(so, NULL); in set_union()
1135 if ((PyObject *)so == other) in set_union()
1151 set_or(PySetObject *so, PyObject *other) in set_or() argument
1155 if (!PyAnySet_Check(so) || !PyAnySet_Check(other)) in set_or()
1158 result = (PySetObject *)set_copy(so, NULL); in set_or()
1161 if ((PyObject *)so == other) in set_or()
1171 set_ior(PySetObject *so, PyObject *other) in set_ior() argument
1176 if (set_update_internal(so, other)) in set_ior()
1178 Py_INCREF(so); in set_ior()
1179 return (PyObject *)so; in set_ior()
1183 set_intersection(PySetObject *so, PyObject *other) in set_intersection() argument
1190 if ((PyObject *)so == other) in set_intersection()
1191 return set_copy(so, NULL); in set_intersection()
1193 result = (PySetObject *)make_new_set_basetype(Py_TYPE(so), NULL); in set_intersection()
1201 if (PySet_GET_SIZE(other) > PySet_GET_SIZE(so)) { in set_intersection()
1202 tmp = (PyObject *)so; in set_intersection()
1203 so = (PySetObject *)other; in set_intersection()
1210 rv = set_contains_entry(so, key, hash); in set_intersection()
1235 rv = set_contains_entry(so, key, hash); in set_intersection()
1258 set_intersection_multi(PySetObject *so, PyObject *args) in set_intersection_multi() argument
1261 PyObject *result = (PyObject *)so; in set_intersection_multi()
1264 return set_copy(so, NULL); in set_intersection_multi()
1266 Py_INCREF(so); in set_intersection_multi()
1286 set_intersection_update(PySetObject *so, PyObject *other) in set_intersection_update() argument
1290 tmp = set_intersection(so, other); in set_intersection_update()
1293 set_swap_bodies(so, (PySetObject *)tmp); in set_intersection_update()
1299 set_intersection_update_multi(PySetObject *so, PyObject *args) in set_intersection_update_multi() argument
1303 tmp = set_intersection_multi(so, args); in set_intersection_update_multi()
1306 set_swap_bodies(so, (PySetObject *)tmp); in set_intersection_update_multi()
1315 set_and(PySetObject *so, PyObject *other) in set_and() argument
1317 if (!PyAnySet_Check(so) || !PyAnySet_Check(other)) in set_and()
1319 return set_intersection(so, other); in set_and()
1323 set_iand(PySetObject *so, PyObject *other) in set_iand() argument
1329 result = set_intersection_update(so, other); in set_iand()
1333 Py_INCREF(so); in set_iand()
1334 return (PyObject *)so; in set_iand()
1338 set_isdisjoint(PySetObject *so, PyObject *other) in set_isdisjoint() argument
1343 if ((PyObject *)so == other) { in set_isdisjoint()
1344 if (PySet_GET_SIZE(so) == 0) in set_isdisjoint()
1354 if (PySet_GET_SIZE(other) > PySet_GET_SIZE(so)) { in set_isdisjoint()
1355 tmp = (PyObject *)so; in set_isdisjoint()
1356 so = (PySetObject *)other; in set_isdisjoint()
1360 rv = set_contains_entry(so, entry->key, entry->hash); in set_isdisjoint()
1381 rv = set_contains_entry(so, key, hash); in set_isdisjoint()
1402 set_difference_update_internal(PySetObject *so, PyObject *other) in set_difference_update_internal() argument
1404 if ((PyObject *)so == other) in set_difference_update_internal()
1405 return set_clear_internal(so); in set_difference_update_internal()
1415 if ((PySet_GET_SIZE(other) >> 3) > PySet_GET_SIZE(so)) { in set_difference_update_internal()
1416 other = set_intersection(so, other); in set_difference_update_internal()
1424 if (set_discard_entry(so, entry->key, entry->hash) < 0) { in set_difference_update_internal()
1437 if (set_discard_key(so, key) < 0) { in set_difference_update_internal()
1449 if ((size_t)(so->fill - so->used) <= (size_t)so->mask / 4) in set_difference_update_internal()
1451 return set_table_resize(so, so->used>50000 ? so->used*2 : so->used*4); in set_difference_update_internal()
1455 set_difference_update(PySetObject *so, PyObject *args) in set_difference_update() argument
1461 if (set_difference_update_internal(so, other)) in set_difference_update()
1471 set_copy_and_difference(PySetObject *so, PyObject *other) in set_copy_and_difference() argument
1475 result = set_copy(so, NULL); in set_copy_and_difference()
1485 set_difference(PySetObject *so, PyObject *other) in set_difference() argument
1501 return set_copy_and_difference(so, other); in set_difference()
1504 /* If len(so) much more than len(other), it's more efficient to simply copy in set_difference()
1505 * so and then iterate other looking for common elements. */ in set_difference()
1506 if ((PySet_GET_SIZE(so) >> 2) > other_size) { in set_difference()
1507 return set_copy_and_difference(so, other); in set_difference()
1510 result = make_new_set_basetype(Py_TYPE(so), NULL); in set_difference()
1515 while (set_next(so, &pos, &entry)) { in set_difference()
1533 /* Iterate over so, checking for common elements in other. */ in set_difference()
1534 while (set_next(so, &pos, &entry)) { in set_difference()
1553 set_difference_multi(PySetObject *so, PyObject *args) in set_difference_multi() argument
1559 return set_copy(so, NULL); in set_difference_multi()
1562 result = set_difference(so, other); in set_difference_multi()
1581 set_sub(PySetObject *so, PyObject *other) in set_sub() argument
1583 if (!PyAnySet_Check(so) || !PyAnySet_Check(other)) in set_sub()
1585 return set_difference(so, other); in set_sub()
1589 set_isub(PySetObject *so, PyObject *other) in set_isub() argument
1593 if (set_difference_update_internal(so, other)) in set_isub()
1595 Py_INCREF(so); in set_isub()
1596 return (PyObject *)so; in set_isub()
1600 set_symmetric_difference_update(PySetObject *so, PyObject *other) in set_symmetric_difference_update() argument
1609 if ((PyObject *)so == other) in set_symmetric_difference_update()
1610 return set_clear(so, NULL); in set_symmetric_difference_update()
1616 rv = set_discard_entry(so, key, hash); in set_symmetric_difference_update()
1622 if (set_add_entry(so, key, hash)) { in set_symmetric_difference_update()
1636 otherset = (PySetObject *)make_new_set_basetype(Py_TYPE(so), other); in set_symmetric_difference_update()
1644 rv = set_discard_entry(so, key, hash); in set_symmetric_difference_update()
1650 if (set_add_entry(so, key, hash)) { in set_symmetric_difference_update()
1664 set_symmetric_difference(PySetObject *so, PyObject *other) in set_symmetric_difference() argument
1669 otherset = (PySetObject *)make_new_set_basetype(Py_TYPE(so), other); in set_symmetric_difference()
1672 rv = set_symmetric_difference_update(otherset, (PyObject *)so); in set_symmetric_difference()
1687 set_xor(PySetObject *so, PyObject *other) in set_xor() argument
1689 if (!PyAnySet_Check(so) || !PyAnySet_Check(other)) in set_xor()
1691 return set_symmetric_difference(so, other); in set_xor()
1695 set_ixor(PySetObject *so, PyObject *other) in set_ixor() argument
1701 result = set_symmetric_difference_update(so, other); in set_ixor()
1705 Py_INCREF(so); in set_ixor()
1706 return (PyObject *)so; in set_ixor()
1710 set_issubset(PySetObject *so, PyObject *other) in set_issubset() argument
1721 result = set_issubset(so, tmp); in set_issubset()
1725 if (PySet_GET_SIZE(so) > PySet_GET_SIZE(other)) in set_issubset()
1728 while (set_next(so, &pos, &entry)) { in set_issubset()
1741 set_issuperset(PySetObject *so, PyObject *other) in set_issuperset() argument
1749 result = set_issuperset(so, tmp); in set_issuperset()
1753 return set_issubset((PySetObject *)other, (PyObject *)so); in set_issuperset()
1802 set_add(PySetObject *so, PyObject *key) in set_add() argument
1804 if (set_add_key(so, key)) in set_add()
1815 set_contains(PySetObject *so, PyObject *key) in set_contains() argument
1820 rv = set_contains_key(so, key); in set_contains()
1828 rv = set_contains_key(so, tmpkey); in set_contains()
1835 set_direct_contains(PySetObject *so, PyObject *key) in set_direct_contains() argument
1839 result = set_contains(so, key); in set_direct_contains()
1848 set_remove(PySetObject *so, PyObject *key) in set_remove() argument
1853 rv = set_discard_key(so, key); in set_remove()
1861 rv = set_discard_key(so, tmpkey); in set_remove()
1880 set_discard(PySetObject *so, PyObject *key) in set_discard() argument
1885 rv = set_discard_key(so, key); in set_discard()
1893 rv = set_discard_key(so, tmpkey); in set_discard()
1907 set_reduce(PySetObject *so, PyObject *Py_UNUSED(ignored)) in set_reduce() argument
1912 keys = PySequence_List((PyObject *)so); in set_reduce()
1918 if (_PyObject_LookupAttrId((PyObject *)so, &PyId___dict__, &dict) < 0) { in set_reduce()
1925 result = PyTuple_Pack(3, Py_TYPE(so), args, dict); in set_reduce()
1934 set_sizeof(PySetObject *so, PyObject *Py_UNUSED(ignored)) in set_sizeof() argument
1938 res = _PyObject_SIZE(Py_TYPE(so)); in set_sizeof()
1939 if (so->table != so->smalltable) in set_sizeof()
1940 res = res + (so->mask + 1) * sizeof(setentry); in set_sizeof()
1998 static PyObject *test_c_api(PySetObject *so, PyObject *Py_UNUSED(ignored));
2360 test_c_api(PySetObject *so, PyObject *Py_UNUSED(ignored)) in test_c_api() argument
2366 PyObject *ob = (PyObject *)so; in test_c_api()
2375 /* so.clear(); so |= set("abc"); */ in test_c_api()
2379 set_clear_internal(so); in test_c_api()
2380 if (set_update_internal(so, str)) { in test_c_api()