
VarSave: save all your variables in a file and load it later
What This Project Does
VarSave (https://github.com/vanopdorp/VarSave) is a small but powerful utility that lets you store the entire runtime state of a Python program and load it back later.
It captures:
- all global variables
- all local variables
- all object instances
- nested structures (lists, dicts, sets, etc.)
- cross‑references between objects
With VarSave, you can pause a running script, save everything to a file, and resume later as if nothing ever changed.
The API is intentionally simple:
save_to_file(path)
load_from_file(path)
save_everything()
load_everything(data)
VarSave stores instances, not class definitions, so you must re‑define your classes and functions before loading a snapshot.
This keeps the system predictable and avoids version conflicts.
You can install it with:
pip3 install varsave
Target Audience
VarSave is designed for developers who want a lightweight way to checkpoint or persist the state of a Python program.
It is useful for:
- debugging complex stateful programs
- long‑running scripts that need “save” functionality
- educational or experimental projects
- prototyping systems that require runtime persistence
VarSave is not intended to be a full production‑grade persistence layer or database replacement.
Instead, it’s a practical tool for developers who want to quickly save and restore Python state without building custom serialization logic.
Comparison to Existing Alternatives
VarSave fills a niche that most serialization tools don’t cover:
Compared to dill
- dill can serialize objects, but VarSave manages the entire runtime, not just individual objects
- VarSave automatically:
- inspects the caller’s frame
- collects globals and locals
- restores them into the correct module
- rebuilds object attributes
Compared to databases or ORM systems
- VarSave is not a structured data store
- It is meant for runtime snapshots, not long‑term storage
- No schemas, migrations, or models required
In short:
VarSave is the easiest way to freeze and restore the entire state of a Python program without writing custom serialization code.