You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Doc/c-api/hash.rst
+53-1Lines changed: 53 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,42 +11,94 @@ See also the :c:member:`PyTypeObject.tp_hash` member and :ref:`numeric-hash`.
11
11
12
12
.. versionadded:: 3.2
13
13
14
+
14
15
.. c:type:: Py_uhash_t
15
16
16
17
Hash value type: unsigned integer.
17
18
18
19
.. versionadded:: 3.2
19
20
21
+
22
+
.. c:macro:: Py_HASH_ALGORITHM
23
+
24
+
A numerical value indicating the algorithm for hashing of :class:`str`,
25
+
:class:`bytes`, and :class:`memoryview`.
26
+
27
+
The algorithm name is exposed by :data:`sys.hash_info.algorithm`.
28
+
29
+
.. versionadded:: 3.4
30
+
31
+
32
+
.. c:macro:: Py_HASH_FNV
33
+
Py_HASH_SIPHASH24
34
+
Py_HASH_SIPHASH13
35
+
36
+
Numerical values to compare to :c:macro:`Py_HASH_ALGORITHM` to determine
37
+
which algorithm is used for hashing. The hash algorithm can be configured
38
+
via the configure :option:`--with-hash-algorithm` option.
39
+
40
+
.. versionadded:: 3.4
41
+
Add :c:macro:`!Py_HASH_FNV` and :c:macro:`!Py_HASH_SIPHASH24`.
42
+
43
+
.. versionadded:: 3.13
44
+
Add :c:macro:`!Py_HASH_SIPHASH13`.
45
+
46
+
47
+
.. c:macro:: Py_HASH_CUTOFF
48
+
49
+
Buffers of length in range ``[1, Py_HASH_CUTOFF)`` are hashed using DJBX33A
50
+
instead of the algorithm described by :c:macro:`Py_HASH_ALGORITHM`.
51
+
52
+
- A :c:macro:`!Py_HASH_CUTOFF` of 0 disables the optimization.
53
+
- :c:macro:`!Py_HASH_CUTOFF` must be non-negative and less or equal than 7.
54
+
55
+
32-bit platforms should use a cutoff smaller than 64-bit platforms because
56
+
it is easier to create colliding strings. A cutoff of 7 on 64-bit platforms
57
+
and 5 on 32-bit platforms should provide a decent safety margin.
58
+
59
+
.. versionadded:: 3.4
60
+
61
+
20
62
.. c:macro:: PyHASH_MODULUS
21
63
22
-
The `Mersenne prime <https://en.wikipedia.org/wiki/Mersenne_prime>`_ ``P = 2**n -1``, used for numeric hash scheme.
64
+
The `Mersenne prime <https://en.wikipedia.org/wiki/Mersenne_prime>`_ ``P = 2**n -1``,
65
+
used for numeric hash scheme.
66
+
This corresponds to the :data:`sys.hash_info.modulus` constant.
23
67
24
68
.. versionadded:: 3.13
25
69
70
+
26
71
.. c:macro:: PyHASH_BITS
27
72
28
73
The exponent ``n`` of ``P`` in :c:macro:`PyHASH_MODULUS`.
74
+
This corresponds to the :data:`sys.hash_info.hash_bits` constant.
29
75
30
76
.. versionadded:: 3.13
31
77
78
+
32
79
.. c:macro:: PyHASH_MULTIPLIER
33
80
34
81
Prime multiplier used in string and various other hashes.
35
82
36
83
.. versionadded:: 3.13
37
84
85
+
38
86
.. c:macro:: PyHASH_INF
39
87
40
88
The hash value returned for a positive infinity.
89
+
This corresponds to the :data:`sys.hash_info.inf` constant.
41
90
42
91
.. versionadded:: 3.13
43
92
93
+
44
94
.. c:macro:: PyHASH_IMAG
45
95
46
96
The multiplier used for the imaginary part of a complex number.
97
+
This corresponds to the :data:`sys.hash_info.imag` constant.
47
98
48
99
.. versionadded:: 3.13
49
100
101
+
50
102
.. c:type:: PyHash_FuncDef
51
103
52
104
Hash function definition used by :c:func:`PyHash_GetFuncDef`.
0 commit comments