-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
Expand file tree
/
Copy pathconsts_getter.py
More file actions
20 lines (18 loc) · 711 Bytes
/
consts_getter.py
File metadata and controls
20 lines (18 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
INTERNAL = ROOT / "Include" / "internal"
def get_nsmallnegints_and_nsmallposints() -> tuple[int, int]:
nsmallposints = None
nsmallnegints = None
with open(INTERNAL / "pycore_runtime_structs.h") as infile:
for line in infile:
if line.startswith("#define _PY_NSMALLPOSINTS"):
nsmallposints = int(line.split()[-1])
elif line.startswith("#define _PY_NSMALLNEGINTS"):
nsmallnegints = int(line.split()[-1])
break
else:
raise NotImplementedError
assert nsmallposints
assert nsmallnegints
return nsmallnegints, nsmallposints