_constants.py 751 B

1234567891011121314151617181920212223242526272829303132333435
  1. """
  2. _constants
  3. ======
  4. Constants relevant for the Python implementation.
  5. """
  6. from __future__ import annotations
  7. import platform
  8. import sys
  9. import sysconfig
  10. IS64 = sys.maxsize > 2**32
  11. PY312 = sys.version_info >= (3, 12)
  12. PY314 = sys.version_info >= (3, 14)
  13. PYPY = platform.python_implementation() == "PyPy"
  14. WASM = (sys.platform == "emscripten") or (platform.machine() in ["wasm32", "wasm64"])
  15. ISMUSL = "musl" in (sysconfig.get_config_var("HOST_GNU_TYPE") or "")
  16. # the refcount for self in a chained __setitem__/.(i)loc indexing/method call
  17. REF_COUNT = 2 if PY314 else 3
  18. REF_COUNT_IDX = 2
  19. REF_COUNT_METHOD = 1 if PY314 else 2
  20. CHAINED_WARNING_DISABLED = PYPY
  21. __all__ = [
  22. "IS64",
  23. "ISMUSL",
  24. "PY312",
  25. "PY314",
  26. "PYPY",
  27. "WASM",
  28. ]