Skip to content

Commit 87942d9

Browse files
authored
gh-141004: correctly document Py_HASH_* and PyHASH_* as hash_info attributes (#141233)
1 parent 9c39946 commit 87942d9

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Doc/c-api/hash.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,16 @@ See also the :c:member:`PyTypeObject.tp_hash` member and :ref:`numeric-hash`.
5656
it is easier to create colliding strings. A cutoff of 7 on 64-bit platforms
5757
and 5 on 32-bit platforms should provide a decent safety margin.
5858

59+
This corresponds to the :data:`sys.hash_info.cutoff` constant.
60+
5961
.. versionadded:: 3.4
6062

6163

6264
.. c:macro:: PyHASH_MODULUS
6365
6466
The `Mersenne prime <https://en.wikipedia.org/wiki/Mersenne_prime>`_ ``P = 2**n -1``,
6567
used for numeric hash scheme.
68+
6669
This corresponds to the :data:`sys.hash_info.modulus` constant.
6770

6871
.. versionadded:: 3.13
@@ -71,7 +74,6 @@ See also the :c:member:`PyTypeObject.tp_hash` member and :ref:`numeric-hash`.
7174
.. c:macro:: PyHASH_BITS
7275
7376
The exponent ``n`` of ``P`` in :c:macro:`PyHASH_MODULUS`.
74-
This corresponds to the :data:`sys.hash_info.hash_bits` constant.
7577

7678
.. versionadded:: 3.13
7779

@@ -86,6 +88,7 @@ See also the :c:member:`PyTypeObject.tp_hash` member and :ref:`numeric-hash`.
8688
.. c:macro:: PyHASH_INF
8789
8890
The hash value returned for a positive infinity.
91+
8992
This corresponds to the :data:`sys.hash_info.inf` constant.
9093

9194
.. versionadded:: 3.13
@@ -94,6 +97,7 @@ See also the :c:member:`PyTypeObject.tp_hash` member and :ref:`numeric-hash`.
9497
.. c:macro:: PyHASH_IMAG
9598
9699
The multiplier used for the imaginary part of a complex number.
100+
97101
This corresponds to the :data:`sys.hash_info.imag` constant.
98102

99103
.. versionadded:: 3.13
@@ -111,14 +115,20 @@ See also the :c:member:`PyTypeObject.tp_hash` member and :ref:`numeric-hash`.
111115
112116
Hash function name (UTF-8 encoded string).
113117

118+
This corresponds to the :data:`sys.hash_info.algorithm` constant.
119+
114120
.. c:member:: const int hash_bits
115121
116122
Internal size of the hash value in bits.
117123

124+
This corresponds to the :data:`sys.hash_info.hash_bits` constant.
125+
118126
.. c:member:: const int seed_bits
119127
120128
Size of seed input in bits.
121129

130+
This corresponds to the :data:`sys.hash_info.seed_bits` constant.
131+
122132
.. versionadded:: 3.4
123133

124134

Doc/library/sys.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1176,10 +1176,14 @@ always available. Unless explicitly noted otherwise, all variables are read-only
11761176

11771177
The size of the seed key of the hash algorithm
11781178

1179+
.. attribute:: hash_info.cutoff
1180+
1181+
Cutoff for small string DJBX33A optimization in range ``[1, cutoff)``.
1182+
11791183
.. versionadded:: 3.2
11801184

11811185
.. versionchanged:: 3.4
1182-
Added *algorithm*, *hash_bits* and *seed_bits*
1186+
Added *algorithm*, *hash_bits*, *seed_bits*, and *cutoff*.
11831187

11841188

11851189
.. data:: hexversion

0 commit comments

Comments
 (0)