| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7ac98ae commit 671b4d9
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,7 +22,11 @@ no meaning otherwise. | |||
| 22 | 22 | #define PySet_MINSIZE 8 | |
| 23 | 23 | ||
| 24 | 24 | typedef struct { | |
| 25 | - long hash; /* cached hash code for the entry key */ | ||
| 25 | + /* Cached hash code of the key. Note that hash codes are C longs. | ||
| 26 | + * We have to use Py_ssize_t instead because set_pop() abuses | ||
| 27 | + * the hash field to hold a search finger. | ||
| 28 | + */ | ||
| 29 | + Py_ssize_t hash; | ||
| 26 | 30 | PyObject *key; | |
| 27 | 31 | } setentry; | |
| 28 | 32 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,6 +12,8 @@ What's New in Python 3.2 Alpha 2? | |||
| 12 | 12 | Core and Builtins | |
| 13 | 13 | ----------------- | |
| 14 | 14 | ||
| 15 | + - Issue #9612: The set object is now 64-bit clean under Windows. | ||
| 16 | + | ||
| 15 | 17 | - Issue #8202: sys.argv[0] is now set to '-m' instead of '-c' when searching | |
| 16 | 18 | for the module file to be executed with the -m command line option. | |
| 17 | 19 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -349,7 +349,7 @@ set_table_resize(PySetObject *so, Py_ssize_t minused) | |||
| 349 | 349 | } else { | |
| 350 | 350 | /* ACTIVE */ | |
| 351 | 351 | --i; | |
| 352 | - set_insert_clean(so, entry->key, entry->hash); | ||
| 352 | + set_insert_clean(so, entry->key, (long) entry->hash); | ||
| 353 | 353 | } | |
| 354 | 354 | } | |
| 355 | 355 | ||
@@ -368,7 +368,7 @@ set_add_entry(register PySetObject *so, setentry *entry) | |||
| 368 | 368 | assert(so->fill <= so->mask); /* at least one empty slot */ | |
| 369 | 369 | n_used = so->used; | |
| 370 | 370 | Py_INCREF(entry->key); | |
| 371 | - if (set_insert_key(so, entry->key, entry->hash) == -1) { | ||
| 371 | + if (set_insert_key(so, entry->key, (long) entry->hash) == -1) { | ||
| 372 | 372 | Py_DECREF(entry->key); | |
| 373 | 373 | return -1; | |
| 374 | 374 | } | |
@@ -409,7 +409,7 @@ set_discard_entry(PySetObject *so, setentry *oldentry) | |||
| 409 | 409 | { register setentry *entry; | |
| 410 | 410 | PyObject *old_key; | |
| 411 | 411 | ||
| 412 | - entry = (so->lookup)(so, oldentry->key, oldentry->hash); | ||
| 412 | + entry = (so->lookup)(so, oldentry->key, (long) oldentry->hash); | ||
| 413 | 413 | if (entry == NULL) | |
| 414 | 414 | return -1; | |
| 415 | 415 | if (entry->key == NULL || entry->key == dummy) | |
@@ -660,7 +660,7 @@ set_merge(PySetObject *so, PyObject *otherset) | |||
| 660 | 660 | if (entry->key != NULL && | |
| 661 | 661 | entry->key != dummy) { | |
| 662 | 662 | Py_INCREF(entry->key); | |
| 663 | - if (set_insert_key(so, entry->key, entry->hash) == -1) { | ||
| 663 | + if (set_insert_key(so, entry->key, (long) entry->hash) == -1) { | ||
| 664 | 664 | Py_DECREF(entry->key); | |
| 665 | 665 | return -1; | |
| 666 | 666 | } | |
@@ -694,7 +694,7 @@ set_contains_entry(PySetObject *so, setentry *entry) | |||
| 694 | 694 | PyObject *key; | |
| 695 | 695 | setentry *lu_entry; | |
| 696 | 696 | ||
| 697 | - lu_entry = (so->lookup)(so, entry->key, entry->hash); | ||
| 697 | + lu_entry = (so->lookup)(so, entry->key, (long) entry->hash); | ||
| 698 | 698 | if (lu_entry == NULL) | |
| 699 | 699 | return -1; | |
| 700 | 700 | key = lu_entry->key; | |
@@ -769,14 +769,14 @@ frozenset_hash(PyObject *self) | |||
| 769 | 769 | if (so->hash != -1) | |
| 770 | 770 | return so->hash; | |
| 771 | 771 | ||
| 772 | - hash *= PySet_GET_SIZE(self) + 1; | ||
| 772 | + hash *= (long) PySet_GET_SIZE(self) + 1; | ||
| 773 | 773 | while (set_next(so, &pos, &entry)) { | |
| 774 | 774 | /* Work to increase the bit dispersion for closely spaced hash | |
| 775 | 775 | values. The is important because some use cases have many | |
| 776 | 776 | combinations of a small number of elements with nearby | |
| 777 | 777 | hashes so that many distinct combinations collapse to only | |
| 778 | 778 | a handful of distinct hash values. */ | |
| 779 | - h = entry->hash; | ||
| 779 | + h = (long) entry->hash; | ||
| 780 | 780 | hash ^= (h ^ (h << 16) ^ 89869747L) * 3644798167u; | |
| 781 | 781 | } | |
| 782 | 782 | hash = hash * 69069L + 907133923L; | |
@@ -816,7 +816,7 @@ setiter_len(setiterobject *si) | |||
| 816 | 816 | Py_ssize_t len = 0; | |
| 817 | 817 | if (si->si_set != NULL && si->si_used == si->si_set->used) | |
| 818 | 818 | len = si->len; | |
| 819 | - return PyLong_FromLong(len); | ||
| 819 | + return PyLong_FromSsize_t(len); | ||
| 820 | 820 | } | |
| 821 | 821 | ||
| 822 | 822 | PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it))."); | |
@@ -1547,7 +1547,7 @@ set_difference(PySetObject *so, PyObject *other) | |||
| 1547 | 1547 | setentry entrycopy; | |
| 1548 | 1548 | entrycopy.hash = entry->hash; | |
| 1549 | 1549 | entrycopy.key = entry->key; | |
| 1550 | - if (!_PyDict_Contains(other, entry->key, entry->hash)) { | ||
| 1550 | + if (!_PyDict_Contains(other, entry->key, (long) entry->hash)) { | ||
| 1551 | 1551 | if (set_add_entry((PySetObject *)result, &entrycopy) == -1) { | |
| 1552 | 1552 | Py_DECREF(result); | |
| 1553 | 1553 | return NULL; | |
@@ -2309,7 +2309,7 @@ _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, long *hash) | |||
| 2309 | 2309 | if (set_next((PySetObject *)set, pos, &entry) == 0) | |
| 2310 | 2310 | return 0; | |
| 2311 | 2311 | *key = entry->key; | |
| 2312 | - *hash = entry->hash; | ||
| 2312 | + *hash = (long) entry->hash; | ||
| 2313 | 2313 | return 1; | |
| 2314 | 2314 | } | |
| 2315 | 2315 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments