Skip to main content

Ultra-fast data validation for Python - 28M validations/sec, 3x faster than Rust alternatives

Project description

dhi - Ultra-Fast Data Validation for Python

The fastest data validation library for Python. Powered by Zig for maximum performance.

🚀 Performance

28 million validations/sec - 3x faster than satya (Rust), 3x faster than msgspec (C)

# Validate 10,000 users in 0.36ms
from dhi import _dhi_native

users = [{"name": "Alice", "email": "alice@example.com", "age": 25}, ...]

field_specs = {
    'name': ('string', 2, 100),
    'email': ('email',),
    'age': ('int_positive',),
}

results, valid_count = _dhi_native.validate_batch_direct(users, field_specs)
# 28M users/sec! 🔥

✨ Features

  • �� Fastest: 3x faster than satya (Rust) and msgspec (C)
  • 🎯 24+ Validators: Email, URL, UUID, IPv4, dates, numbers, strings
  • 🔋 Zero Python Overhead: C extension extracts directly from dicts
  • 🌍 General Purpose: Works with any dict structure
  • 💪 Production Ready: Thoroughly tested and benchmarked

📦 Installation

pip install dhi

🎯 Quick Start

from dhi import _dhi_native

users = [
    {"name": "Alice", "email": "alice@example.com", "age": 25},
    {"name": "Bob", "email": "bob@example.com", "age": 30},
]

field_specs = {
    'name': ('string', 2, 100),
    'email': ('email',),
    'age': ('int_positive',),
}

results, valid_count = _dhi_native.validate_batch_direct(users, field_specs)
print(f"Valid: {valid_count}/{len(users)}")

�� Available Validators

String: email, url, uuid, ipv4, base64, iso_date, iso_datetime, string

Number: int, int_gt, int_gte, int_lt, int_lte, int_positive, int_non_negative, int_multiple_of

🏆 Benchmarks

dhi:     28M users/sec  🥇
satya:    9M users/sec  (3.0x slower)
msgspec:  9M users/sec  (3.1x slower)

📝 License

MIT License - see LICENSE file

🔗 Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dhi-1.0.1.tar.gz (22.5 kB view details)

Uploaded Source

File details

Details for the file dhi-1.0.1.tar.gz.

File metadata

  • Download URL: dhi-1.0.1.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for dhi-1.0.1.tar.gz
Algorithm Hash digest
SHA256 8454927247a64ac1413be9193a6ad6d49c6b86bdd238062c5e16adfe855fb4fc
MD5 7cd18d1044f88c180a6b1af9264772be
BLAKE2b-256 33dcb45f045b5beeeec04095b2e657367c61a28727fc5de8d830cccb9ccce907

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page