MCPcopy Index your code
hub / github.com/python/cpython / _load_metadata_from_source

Function _load_metadata_from_source

Tools/scripts/summarize_stats.py:54–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

52
53
54def _load_metadata_from_source():
55 def get_defines(filepath: Path, prefix: str = "SPEC_FAIL"):
56 with open(SOURCE_DIR / filepath) as spec_src:
57 defines = collections.defaultdict(list)
58 start = "#define " + prefix + "_"
59 for line in spec_src:
60 line = line.strip()
61 if not line.startswith(start):
62 continue
63 line = line[len(start) :]
64 name, val = line.split()
65 defines[int(val.strip())].append(name.strip())
66 return defines
67
68 import opcode
69
70 return {
71 "_specialized_instructions": [
72 op for op in opcode._specialized_opmap.keys() if "__" not in op # type: ignore
73 ],
74 "_stats_defines": get_defines(
75 Path("Include") / "cpython" / "pystats.h", "EVAL_CALL"
76 ),
77 "_defines": get_defines(Path("Python") / "specialize.c"),
78 }
79
80
81def load_raw_data(input: Path) -> RawData:

Callers 1

load_raw_dataFunction · 0.85

Calls 3

PathClass · 0.90
get_definesFunction · 0.85
keysMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…