Skip to content
Merged
Prev Previous commit
Next Next commit
More tweaks, broken
  • Loading branch information
emmatyping committed Aug 20, 2022
commit dfba6034ffaf2cf1947d3f17fa3770d021fed9d2
14 changes: 8 additions & 6 deletions mypyc/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@
FAST_ISINSTANCE_MAX_SUBCLASSES: Final = 2

# Size of size_t, if configured.
SIZEOF_SIZE_T: Final = sysconfig.get_config_var("SIZEOF_SIZE_T") or math.log2(sys.maxsize)
SIZEOF_SIZE_T_SYSCONFIG: Final = sysconfig.get_config_var("SIZEOF_SIZE_T")

IS_32_BIT_PLATFORM: Final = (
sys.maxsize < (1 << 31) if SIZEOF_SIZE_T is None else int(SIZEOF_SIZE_T) == 4
SIZEOF_SIZE_T: Final = (
int(SIZEOF_SIZE_T_SYSCONFIG)
if SIZEOF_SIZE_T_SYSCONFIG is not None
else (math.log2(sys.maxsize) + 1) // 8
)

IS_32_BIT_PLATFORM: Final = int(SIZEOF_SIZE_T) == 4

PLATFORM_SIZE = 4 if IS_32_BIT_PLATFORM else 8

# Python 3.5 on macOS uses a hybrid 32/64-bit build that requires some workarounds.
Expand All @@ -49,9 +53,7 @@
IS_MIXED_32_64_BIT_BUILD: Final = sys.platform in ["darwin"] and sys.version_info < (3, 6)

# Maximum value for a short tagged integer.
MAX_SHORT_INT: Final = (
sys.maxsize >> 1 if SIZEOF_SIZE_T is None else 2 ** (8 * int(SIZEOF_SIZE_T) - 2) - 1
)
MAX_SHORT_INT: Final = 2 ** (8 * int(SIZEOF_SIZE_T) - 2) - 1

# Maximum value for a short tagged integer represented as a C integer literal.
#
Expand Down