Hasty Briefsbeta

Bilingual

Memory Snapshots for CPython (Python Language Summit 2026)

2 days ago
  • Hood Chatham proposed using memory snapshots to bypass re-initialization of CPython, achieving up to 4x faster startup for simple programs in Pyodide.
  • A key challenge is that memory snapshots would fix the random hash seed, reintroducing a security risk from hash collision denial-of-service attacks (like the one fixed in Python 3.3).
  • Hood suggested adding an explicit initialization phase to CPython, similar to RPython and SPy, to safely reintroduce randomness when restoring from a snapshot.
  • Discussion touched on alternatives like lazy imports (PEP 810), which might not aid snapshots because imports would not be cached, and freezing modules, which had limited startup improvement in earlier experiments.