mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
make hashes always the size of pointers; introduce Py_hash_t #9778
This commit is contained in:
parent
6fb457526c
commit
8f67d0893f
31 changed files with 137 additions and 131 deletions
|
|
@ -22,11 +22,8 @@ no meaning otherwise.
|
|||
#define PySet_MINSIZE 8
|
||||
|
||||
typedef struct {
|
||||
/* Cached hash code of the key. Note that hash codes are C longs.
|
||||
* We have to use Py_ssize_t instead because set_pop() abuses
|
||||
* the hash field to hold a search finger.
|
||||
*/
|
||||
Py_ssize_t hash;
|
||||
/* Cached hash code of the key. */
|
||||
Py_hash_t hash;
|
||||
PyObject *key;
|
||||
} setentry;
|
||||
|
||||
|
|
@ -53,10 +50,10 @@ struct _setobject {
|
|||
* saves repeated runtime null-tests.
|
||||
*/
|
||||
setentry *table;
|
||||
setentry *(*lookup)(PySetObject *so, PyObject *key, long hash);
|
||||
setentry *(*lookup)(PySetObject *so, PyObject *key, Py_hash_t hash);
|
||||
setentry smalltable[PySet_MINSIZE];
|
||||
|
||||
long hash; /* only used by frozenset objects */
|
||||
Py_hash_t hash; /* only used by frozenset objects */
|
||||
PyObject *weakreflist; /* List of weak references */
|
||||
};
|
||||
|
||||
|
|
@ -93,7 +90,7 @@ PyAPI_FUNC(int) PySet_Clear(PyObject *set);
|
|||
PyAPI_FUNC(int) PySet_Contains(PyObject *anyset, PyObject *key);
|
||||
PyAPI_FUNC(int) PySet_Discard(PyObject *set, PyObject *key);
|
||||
PyAPI_FUNC(int) PySet_Add(PyObject *set, PyObject *key);
|
||||
PyAPI_FUNC(int) _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, long *hash);
|
||||
PyAPI_FUNC(int) _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, Py_hash_t *hash);
|
||||
PyAPI_FUNC(PyObject *) PySet_Pop(PyObject *set);
|
||||
PyAPI_FUNC(int) _PySet_Update(PyObject *set, PyObject *iterable);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue