Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vstinner committed Sep 1, 2023
1 parent 974d26b commit 1969769
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions Include/internal/pycore_long.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,25 +222,15 @@ PyAPI_FUNC(int) _PyLong_Size_t_Converter(PyObject *, void *);
* 2: Reserved for immortality bit
* 3+ Unsigned digit count
*/
#define SIGN_MASK 3
#define SIGN_MASK _PyLong_SIGN_MASK
#define SIGN_ZERO 1
#define SIGN_NEGATIVE 2
#define NON_SIZE_BITS 3
#define NON_SIZE_BITS _PyLong_NON_SIZE_BITS

/* The functions _PyLong_IsCompact and _PyLong_CompactValue are defined
* in Include/cpython/longobject.h, since they need to be inline.
*
* "Compact" values have at least one bit to spare,
/* "Compact" values have at least one bit to spare,
* so that addition and subtraction can be performed on the values
* without risk of overflow.
*
* The inline functions need tag bits.
* For readability, rather than do `#define SIGN_MASK _PyLong_SIGN_MASK`
* we define them to the numbers in both places and then assert that
* they're the same.
*/
static_assert(SIGN_MASK == _PyLong_SIGN_MASK, "SIGN_MASK does not match _PyLong_SIGN_MASK");
static_assert(NON_SIZE_BITS == _PyLong_NON_SIZE_BITS, "NON_SIZE_BITS does not match _PyLong_NON_SIZE_BITS");

/* All *compact" values are guaranteed to fit into
* a Py_ssize_t with at least one bit to spare.
Expand Down

0 comments on commit 1969769

Please sign in to comment.