polars-checkpoint
Materialise Polars LazyFrames to parquet files and scan them back lazily. Defaults to the streaming engine for sink/scan. Useful for managing & reducing memory pressure due to expensive intermediate results in complex multi-step transforms.
Installation
Requires polars and Python 3.10+.
Quick Start
import polars as pl
from polars_checkpoint import checkpoint
lf = pl.LazyFrame({"x": range(1_000_000)}).with_columns(y=pl.col("x") * 2)
# Materialises to a temp parquet file; returns a lazy re-scan
lf = checkpoint(lf)
lf.filter(pl.col("y") > 100).collect()
A process-wide default session manages the temp directory and cleans it up at exit.
Session API
For explicit control over storage location and lifecycle, use CheckpointSession:
from polars_checkpoint import CheckpointSession
# As a context manager — cleans up on exit from the block
with CheckpointSession(root_dir="./my_checkpoints") as sess:
lf = pl.scan_csv("big.csv")
lf = sess.checkpoint(lf, name="after-parse")
lf = lf.filter(pl.col("status") == "active")
lf = sess.checkpoint(lf, name="filtered")
# Without a context manager — cleans up at GC or interpreter shutdown,
# or when you call close() explicitly
sess = CheckpointSession(root_dir="./my_checkpoints")
lf = sess.checkpoint(pl.scan_csv("big.csv"), name="raw")
reloaded = sess["raw"]
print(sess.summary())
sess.close() # optional; triggers early cleanup
CheckpointSession constructor
| Parameter | Default | Description |
|---|---|---|
root_dir |
None (auto temp dir) |
Parent directory for checkpoint folders. |
cleanup |
True |
Delete checkpoint files on close / GC / interpreter exit. |
default_sink_kwargs |
{"compression": "zstd"} |
Defaults passed to sink_parquet / write_parquet. |
default_scan_kwargs |
{} |
Defaults passed to scan_parquet. |
Key methods & features
checkpoint(lf, *, name=None, streaming=True, ...)— Materialise a LazyFrame to parquet. Auto-generates a name if none given. Falls back tocollect().write_parquet()whenstreaming=False.session[name]— Retrieve a checkpoint as aLazyFrame.name in session— Check existence.len(session)/iter(session)— Count / list checkpoints.summary()— Returns a Polars DataFrame with name, size (MB), and path of each checkpoint.close(timeout=None)— Waits for in-flight writes, then cleans up. Also usable as a context manager.
Thread Safety
Sessions are internally locked. Concurrent checkpoint() calls from multiple threads are safe; close() waits for all in-flight materialisations before removing files.
Cleanup Behaviour
| Scenario | cleanup=True (default) |
cleanup=False |
|---|---|---|
close() / __exit__ |
Files deleted | Files retained |
| GC / interpreter shutdown | Files deleted (via weakref.finalize) |
Files retained |
When root_dir is auto-generated, the entire temp directory is removed. When user-supplied, only the individual checkpoint subdirectories created by the session are removed.
Metadata
Release files for polars-checkpoint 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| polars_checkpoint-0.1.5.tar.gz | 7.5 kB | Without provenance | Details for polars_checkpoint-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| polars_checkpoint-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for polars_checkpoint-0.1.5-py3-none-any.whl |
Total release size: 16.1 kB
Release files / polars_checkpoint-0.1.5.tar.gz
| Download URL | polars_checkpoint-0.1.5.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b6b6bc356af6ab5ce2436ea577b753334c86c714b931622d983ce444146ec275
|
|
BLAKE2b-256 checksum How to use checksums |
a65e038eda1513426fa310ad8e023c29e33b820fc7f536c8c67a3d0623b6baa6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / polars_checkpoint-0.1.5-py3-none-any.whl
| Download URL | polars_checkpoint-0.1.5-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
83e9e95cfca64465a0303e258369c9f227d8437c0083ef5a41acf60c75a4695b
|
|
BLAKE2b-256 checksum How to use checksums |
9115436f0fe3dc227275a24367c348368153d7983c1f59dd7a60bab174b85c8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for polars-checkpoint 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.