Skip to content

Commit

Permalink
Expose macros as public and move docs to Doc/c-api/hash.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Nov 15, 2023
1 parent b7a7ce3 commit 7080fa9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 25 deletions.
15 changes: 15 additions & 0 deletions Doc/c-api/hash.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ See also the :c:member:`PyTypeObject.tp_hash` member.

.. versionadded:: 3.2

.. c:macro:: PyHASH_MODULUS
The Mersenne prime ``P = 2**n -1``, used for numeric hash scheme.

.. c:macro:: PyHASH_BITS
The exponent ``n`` of ``P``.

.. c:macro:: PyHASH_INF
The hash value returned for a positive infinity.

.. c:macro:: PyHASH_IMAG
The multiplier used for the imaginary part of a complex number.

.. c:type:: PyHash_FuncDef
Expand Down
20 changes: 0 additions & 20 deletions Doc/c-api/hashing.rst

This file was deleted.

1 change: 0 additions & 1 deletion Doc/c-api/utilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ and parsing function arguments and constructing Python values from C values.
reflection.rst
codec.rst
perfmaps.rst
hashing.rst
8 changes: 4 additions & 4 deletions Include/pyhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ extern "C" {
# define _PyHASH_BITS 31
#endif

#define PyUnstable_PyHASH_BITS _PyHASH_BITS
#define PyHASH_BITS _PyHASH_BITS

#define _PyHASH_MODULUS (((size_t)1 << _PyHASH_BITS) - 1)
#define PyUnstable_PyHASH_MODULUS _PyHASH_MODULUS
#define PyHASH_MODULUS _PyHASH_MODULUS
#define _PyHASH_INF 314159
#define PyUnstable_PyHASH_INF _PyHASH_INF
#define PyHASH_INF _PyHASH_INF
#define _PyHASH_IMAG _PyHASH_MULTIPLIER
#define PyUnstable_PyHASH_IMAG _PyHASH_IMAG
#define PyHASH_IMAG _PyHASH_IMAG

/* Cutoff for small string DJBX33A optimization in range [1, cutoff).
*
Expand Down

0 comments on commit 7080fa9

Please sign in to comment.