Skip to main content

Dalga (🌊)

PyPI version License: MIT

A blazing-fast, O(1) memory streaming data profiler. Written in Rust, built for Python.

Dalga acts as an in-stream observability layer and circuit breaker. It sits natively inside your existing data pipelines (Kafka, FastAPI, Pandas, Polars) and calculates statistical sketches of your data in real-time. It intercepts silent data corruption before it reaches your data warehouse, all without adding latency to your workers.

Why Dalga?

  • Zero Compute Cost: Stop querying multi-terabyte warehouse tables just to monitor null rates or cardinality. Dalga profiles the data before it lands.
  • Lock-Free Concurrency: Built on a double-buffered ArcSwap and atomic counters. Multiple threads can hammer the engine simultaneously with zero lock contention.
  • Bounded O(1) Memory: Utilizes 14-bit HyperLogLogPlus algorithms to estimate cardinality. Whether you process 100 rows or 10 billion, Dalga uses exactly ~16KB of memory per column.
  • Fail-Open & Safe: Designed for mission-critical pipelines. If the telemetry fails, or if it encounters malformed bytes, Dalga gracefully drops the bad data and keeps your pipeline running.
  • Framework Agnostic: First-class adapters for Pandas, Polars, FastAPI, and confluent-kafka.

Installation

Dalga is available on PyPI. You can install it using uv, pip, or your preferred package manager:

uv add dalga-core
# or
pip install dalga-core

(Note: The package name is dalga-core, but the import namespace is dalga)


Quickstart

Dalga processes data locally in an isolated Rust memory space. It automatically flushes metadata payloads in the background without blocking your host application.

1. The Core Engine (Batch Processing)

For standard lists of dictionaries or JSON payloads, use the universal .flow() method. The Rust engine natively processes batches for maximum throughput.

from dalga.core import DalgaClient

dalga = DalgaClient()

# Pass batches directly to bypass Python iteration overhead
batch_data = [
    {"user_id": 1, "status": "active"}, 
    {"user_id": 2, "status": "banned"}
]
dalga.flow(batch_data)

2. The Circuit Breaker (Data Quality Gates)

Dalga actively protects your database from silent corruption. Evaluate incoming batches against strict Expectation rules. If a batch violates the rules, Dalga rejects it before it pollutes your global state or warehouse.

from dalga.core import DalgaClient, Expectation

dalga = DalgaClient()

rules = [
    Expectation("price").min_value(0.0),            # No negative prices
    Expectation("user_id").to_not_be_null(),        # User ID is required
    Expectation("category").max_null_ratio(0.50)    # Category can be null up to 50%
]

batch = fetch_kafka_messages()

# Evaluates the batch in an isolated Rust memory space
if dalga.validate(batch, rules):
    insert_to_snowflake(batch)
else:
    send_to_dead_letter_queue(batch)

3. The Kafka Adapter

Drop Dalga directly into your consumer poll() loop to profile high-throughput streams natively.

from dalga.core import DalgaClient
from dalga.adapters.kafka import DalgaKafka

dalga = DalgaClient(max_records=10_000)
kafka_adapter = DalgaKafka(dalga)

while True:
    messages = consumer.consume(num_messages=2000, timeout=1.0)
    if not messages:
        continue

    # Parses raw bytes and profiles the entire micro-batch instantly in Rust
    kafka_adapter.profile_batch(messages)

    # ... your normal DB insertion logic ...

4. DataFrames (Pandas & Polars)

Monitor batch transformations instantly. Importing the adapters automatically registers the .dalga namespace to your DataFrames.

import pandas as pd
import polars as pl
from dalga.core import DalgaClient
import dalga.adapters.pandas 
import dalga.adapters.polars

dalga = DalgaClient()

# Pandas
df_pd = pd.read_csv("daily_users.csv")
df_pd.dalga.profile(dalga)

# Polars
df_pl = pl.read_parquet("daily_users.parquet")
df_pl.dalga.profile(dalga)

5. The FastAPI Middleware

Monitor the shape of incoming JSON payloads asynchronously without starving your endpoint streams.

from fastapi import FastAPI
from dalga.core import DalgaClient
from dalga.adapters.fastapi import DalgaMiddleware

dalga = DalgaClient()
app = FastAPI()

# Profile specific endpoints (or all traffic) safely
app.add_middleware(DalgaMiddleware, client=dalga, endpoints_to_monitor=["/ingest"])

@app.post("/ingest")
async def ingest_data(payload: dict):
    return {"status": "success"}

Architecture (Under the Hood)

Dalga leverages PyO3 to bridge Python directly to a highly optimized Rust engine.

  1. Zero-Copy Extraction: Python dictionaries are evaluated at the FFI boundary, extracting types (Int, Float, Str, Null) without expensive string parsing allocations.
  2. Lock-Free Aggregation: The Rust core calculates Min, Max, and Nulls using atomic counters. Thread contention is virtually eliminated, even on extremely hot columns.
  3. Double-Buffered Flushes: Background flushes utilize ArcSwap to atomically swap the active DashMap in O(1) time. Ingestion threads never block waiting for serialization.
  4. Absolute Memory Bounds: Unique values are hashed into a HyperLogLogPlus sketch, ensuring memory utilization remains flat regardless of dataset size.

Local Development

Dalga uses nix, uv, and maturin for reproducible builds.

# Enter the reproducible dev environment
nix develop

# Sync dependencies and compile the Rust extension
uv sync
uv run maturin develop --release

# Run the test suite
uv run pytest tests/ -v

Metadata

Release files for dalga-core 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dalga-core 0.1.0
File Size Uploaded Provenance Actions
dalga_core-0.1.0.tar.gz 50.4 kB With provenance Details for dalga_core-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for dalga-core 0.1.0
File Interpreter ABI Platform Actions
dalga_core-0.1.0-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details for dalga_core-0.1.0-cp38-abi3-win_amd64.whl
dalga_core-0.1.0-cp38-abi3-manylinux_2_34_x86_64.whl CPython 3.8 abi3 Linux glibc 2.34+ x86-64 Details for dalga_core-0.1.0-cp38-abi3-manylinux_2_34_x86_64.whl
dalga_core-0.1.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl CPython 3.8 abi3 macOS 10.12+ x86-64, macOS 10.12+ universal2 (ARM64, x86-64), macOS 11.0+ ARM64 Details for dalga_core-0.1.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Total release size: 1.3 MB

Release files / dalga_core-0.1.0.tar.gz

Download URL dalga_core-0.1.0.tar.gz
Size 50.4 kB
Tags Source
SHA-256 checksum
How to use checksums
824c69082ace94c85a2f74a6c52a8b15072b0988f13c0a1082669af824b69eef
BLAKE2b-256 checksum
How to use checksums
ef953bb7e93af982b10bd3706924c6625b86811f198b22c63d66b28224106a68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 19, 2026.

Transparency log

Release files / dalga_core-0.1.0-cp38-abi3-win_amd64.whl

Download URL dalga_core-0.1.0-cp38-abi3-win_amd64.whl
Size 213.9 kB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
0aaba67834c72c2885edc88bb5424366ec7c0fb3261883fa537b3445ffa84d85
BLAKE2b-256 checksum
How to use checksums
4bd4e3a6b00c63477df8d9fa3121c5f3bc344e2cb70726b862893905ef0247ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 19, 2026.

Transparency log

Release files / dalga_core-0.1.0-cp38-abi3-manylinux_2_34_x86_64.whl

Download URL dalga_core-0.1.0-cp38-abi3-manylinux_2_34_x86_64.whl
Size 369.1 kB
Tags CPython 3.8 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
7979eefa762549ab55b31cf05052477b6030cf3500c1037b8bb5080f25029556
BLAKE2b-256 checksum
How to use checksums
372b9125457543a46b77af69c1d89211f2a5bf96c4405360d1c94c04028ebdcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 19, 2026.

Transparency log

Release files / dalga_core-0.1.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Download URL dalga_core-0.1.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Size 627.1 kB
Tags CPython 3.8 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
33fbc78d64e80671f7d056d70cd0793f26c8fd16e367f95bd203e84f32b67caf
BLAKE2b-256 checksum
How to use checksums
efd2c961eb2a0874d150cce3e25958d2292bc2ed963d71eeb733d0a6575e34b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 19, 2026.

Transparency log

Security for dalga-core 0.1.0

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.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for dalga_core-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 19, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

4 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page