MCPcopy Index your code
hub / github.com/python/mypy / _load_cached_group_files

Function _load_cached_group_files

mypyc/codegen/emitmodule.py:381–404  ·  view source on GitHub ↗

Read the .c/.h paths recorded for this group on the previous run. All modules in a group share the same src_hashes map, so the first readable IR cache is sufficient. Returns paths paired with empty content so callers can distinguish "reuse on disk" from "newly generated".

(
    group_sources: list[BuildSource], result: BuildResult
)

Source from the content-addressed store, hash-verified

379
380
381def _load_cached_group_files(
382 group_sources: list[BuildSource], result: BuildResult
383) -> list[tuple[str, str]]:
384 """Read the .c/.h paths recorded for this group on the previous run.
385
386 All modules in a group share the same src_hashes map, so the first
387 readable IR cache is sufficient. Returns paths paired with empty
388 content so callers can distinguish "reuse on disk" from "newly
389 generated".
390 """
391 for source in group_sources:
392 state = result.graph.get(source.module)
393 if state is None:
394 continue
395 try:
396 ir_json = result.manager.metastore.read(get_state_ir_cache_name(state))
397 except (FileNotFoundError, OSError):
398 continue
399 try:
400 ir_data = json.loads(ir_json)
401 except json.JSONDecodeError:
402 continue
403 return [(path, "") for path in ir_data.get("src_hashes", {})]
404 return []
405
406
407def get_ir_cache_name(id: str, path: str, options: Options) -> str:

Callers 1

compile_ir_to_cFunction · 0.85

Calls 3

get_state_ir_cache_nameFunction · 0.85
getMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…