Repository navigation
Runtime and Performance
The universal wheel and source distribution ship Python and C sources. Installing or importing DataShoal leaves the compiler idle. The first accelerated operation triggers a local build under CPython. Template rendering, Parquet codecs, Arrow text and binary columns, SafeTensors header preflight and POSIX bulk reads, and Xet hashing, chunking, and LZ4 decoding use that accelerator.
Install a C11 compiler and development headers matching the running interpreter; on Windows use MSVC in a configured developer environment. Set CC to select the compiler. Set DATASHOAL_JIT_CACHE to choose a private cache directory. The default is under $XDG_CACHE_HOME/datashoal/jit (normally ~/.cache/datashoal/jit), or LOCALAPPDATA on Windows when set. The cache key includes sources, interpreter, ABI, architecture and compiler configuration. Concurrent first-use calls coordinate the build; later processes can load the completed artifact.
If CPython, matching headers, or a working compiler is unavailable, DataShoal uses the slower Python implementations and logs the reason once per process. A failed extension load also uses the Python fallback. After fixing the reported issue, start a new Python process to retry.
Each iteration over a native dataset owns its cursor and can run concurrently with other passes. Threads advancing the same cursor divide its rows between them exactly once, in scheduler-dependent order. Custom callbacks must synchronize shared mutable state. A materialized compatibility dataset returns detached nested values. Partitioning the input for calibration and preserving deterministic ordering remain application choices.
Use take(n) for a preview, sample(n, seed=...) for a bounded-memory representative sample, and collect() for a fully materialized Python result. Parquet projection reduces work when only certain columns are needed. Typed page buffers avoid creating one Python dictionary per numeric ID.
The project benchmark measures end-to-end local reads into equivalent Python rows or contiguous numeric arrays, and writes from the same Python rows. It compares warm runs after JIT compilation. Datasets streaming reads the source Parquet; Datasets cached reopens a prepared Arrow cache with preparation outside the timer. Use the same result type and cache state when comparing your own workload. The checked-in benchmark validates equal outputs before timing. Benchmark script
The README compares full collection and streamed consumption of equal Python rows from the same local chat data. The benchmark checks a SHA-256 digest of every row in order. Each library and mode runs in three fresh processes. Time is the median of their warm medians (17 timed scans for 10,000 rows and 9 for 100,000). Peak resident memory is the median whole-process high-water mark after the first scan, including library imports. HF Datasets uses its prepared cache for collection and its Parquet source for streaming. Batch size is 1,024. The machine was an Apple M5 Ultra with CPython 3.12.14.
python -m pip install . 'pyarrow==26.0.1' 'datasets==5.2.0' 'numpy==2.5.5'
curl -fL https://huggingface.co/datasets/neuralmagic/calibration/resolve/fb6bc2f8c66543876fb31613f5872b9030220e15/llm.parquet -o llm.parquet
python benchmarks/read_modes.py llm.parquet --runs 17Generate the larger fixture by repeating the original ten row groups ten times with PyArrow 26.0.1:
import pyarrow.parquet as pq
with pq.ParquetFile("llm.parquet") as source:
with pq.ParquetWriter("large.parquet", source.schema_arrow, compression="snappy") as out:
for _ in range(10):
for i in range(source.num_row_groups):
out.write_table(source.read_row_group(i))Run python benchmarks/read_modes.py large.parquet --runs 9. Decode speed depends on page layout, compression, projection and output type. Comparison harness
The README's size-and-speed table uses a Linux arm64 NVIDIA GB10 host with CPython 3.12.14. Run the local Parquet and SafeTensors benchmarks with the reference versions below. First-use compilation and prepared-cache creation stay outside the timer. The benchmark scripts verify equivalent output. Divide DataShoal LOC by reference LOC for the LOC factor. Below 1× means DataShoal uses fewer lines. Divide reference time by DataShoal time for the speed factor. Above 1× means DataShoal runs faster.
python -m pip install . 'pyarrow==26.0.1' 'datasets==5.2.0' 'numpy==2.5.5' 'safetensors==0.8.0' 'jinja2==3.1.6'
curl -fL https://huggingface.co/datasets/neuralmagic/calibration/resolve/fb6bc2f8c66543876fb31613f5872b9030220e15/llm.parquet -o llm.parquet
PYTHONPATH=. python benchmarks/parquet.py llm.parquet --runs 31
PYTHONPATH=. python benchmarks/tensors.py --mib 64 --runs 31
PYTHONPATH=. python benchmarks/templates.pyCount nonblank physical source lines in the package roots below. Include Python, Cython, C, C++, and Rust sources and headers. Exclude test and benchmark files and directories, thirdparty, third_party, and vendored directories, and binaries.
| Source distribution | Counted roots |
|---|---|
| DataShoal 0.1.1 | datashoal/ |
| PyArrow 26.0.1 | Python, Cython, and C++ binding sources in the source distribution's pyarrow/ tree |
| HF Datasets 5.2.0 | src/datasets/ |
| DataShoal SafeTensors |
safetensors.py, wire.py, tensor_layout.py, torch_ranges.py, _torch_tensors.py, _compat_safetensors.py, and native/safetensors.h under datashoal/
|
| SafeTensors 0.8.0 |
bindings/python/src/, safetensors/src/, and __init__.py, numpy.py, and torch.py in the source distribution's py_src/safetensors/
|
| DataShoal template subset |
datashoal/native/template.h, datashoal/_template_fallback.py, and datashoal/templates.py
|
| Jinja2 3.1.6 | Full src/jinja2/ package |
The PyArrow count is 72,760 nonblank LOC across 156 source files in its Python bindings. The separately built Apache Arrow C++ runtime runs the native operations measured by the benchmark. The HF Datasets count is 43,311 nonblank LOC across 154 files in its Python package. Both package counts compare against all 6,987 lines of DataShoal. PyArrow 26.0.1 sources · HF Datasets 5.2.0 sources
The template comparison counts 926 lines for DataShoal's C11 and Python implementations of the subset and its public wrapper. Jinja2's 11,692 lines cover its full Python package. The fixture renders syntax they both support. Jinja2 3.1.6 sources
The SafeTensors rows compare checkpoint-specific modules. DataShoal's seven dedicated files total 1,410 nonblank LOC. SafeTensors 0.8.0 has 4,122 Rust LOC in its core and native Python binding after removing the trailing inline Rust test modules in bindings/python/src/lib.rs, safetensors/src/slice.rs, and safetensors/src/tensor.rs. Its package initializer has 11 lines, the NumPy adapter has 156, and the PyTorch adapter has 503, for a scoped total of 4,792 and a LOC factor of 0.29×. Counting all its Python adapters gives 5,363 total production LOC. The 6,987-line DataShoal package total also covers its shared API, native loader, dataset, Hub, and template code. SafeTensors 0.8.0 source distribution
Pass --workdir to the SafeTensors benchmark to choose the filesystem. Pass --chunk-kib to repeat the same workload at I/O caps from 64 KiB to 64 MiB. For the independent native read sweep, hold one 256 MiB archive open, call wire_read at each chunk limit in alternating order, and compare each result's checksum before timing. The default 64 MiB bulk cap keeps the fastest measured read and lies on the flat part of the write curve.
The template benchmark compares byte-identical output for 810 CUDA declarations using DataShoal's C11 and Python backends and Jinja2. It parses the template once per backend before timing and reports the median of 101 renders in a fixed randomized order.
With the same environment and downloaded chat shard, run HF_HUB_OFFLINE=1 python benchmarks/parquet.py llm.parquet --runs 51. Each value is the median of 51 timed operations in one process after warm-up, with implementation order randomized each round. The script also generates 250,000 integer IDs and checks agreement on both Python rows and NumPy arrays. In this comparison the HF streaming reader collects its batches into the requested full output. Both writers use uncompressed Parquet with 1,000 rows per group. README results
Run python benchmarks/tensors.py --mib 64 --runs 25 with NumPy and reference SafeTensors 0.8.0 installed for comparison. Each backend reads the same local I32 file into independently owned bytes. The streaming case consumes 1 MiB chunks. The Rust-backed reader uses its NumPy binding and converts each result to bytes. Framework views have different ownership and are outside this measurement. Writes start from the same contiguous array and finish when the file is closed. DataShoal uses an atomic replacement. Neither writer benchmark requests a durable disk flush. The harness alternates implementations in randomized order, reports medians after warm-up and checks payload hashes in both directions. Comparison harness
Get started
- Installation and quickstart
- Python API reference
- Native templates
- Native extension ABI
- Loading reference
Prepare calibration data
Manage artifacts
Operate and contribute