Skip to main content

formatparse

PyPI version Python 3.8+ License: MIT Rust Documentation

A Rust-backed reimplementation of the parse library for Python. It targets the same parse / search / findall workflow with substantially lower overhead on hot paths (performance guide). Use it as a drop-in replacement for common parse patterns; see the migration guide for edge-case differences.

Documentation

Full documentation: https://formatparse.readthedocs.io/

Features

  • Fast: Rust backend with pattern caching and batch APIs (benchmarks)
  • Drop-in replacement: Compatible with common parse usage (migration guide)
  • Pattern matching: Named and positional fields, custom types, nested specs
  • DateTime parsing: ISO 8601, log timestamps, strftime, and more
  • Case-sensitive and case-insensitive matching (matching behavior)
  • Validation and bidirectional patterns for round-trip format/parse workflows

Installation

pip install formatparse

From source, see Installation in the docs.

Quick Start

from formatparse import parse, search, findall

result = parse("{name}: {age:d}", "Alice: 30")
print(result.named["name"], result.named["age"])  # Alice 30

More examples: Getting Started.

Malformed patterns: parse vs compile

For some invalid patterns (for example a missing } after a field), parse returns None while compile raises PatternParseMismatch. See the migration guide.

Custom types (extra_types)

Use @with_pattern and an extra_types dict — see the Custom types guide. Caching and pickling notes are documented there and in FAQ.

Contributing

See CONTRIBUTING.md and the Contributing docs page.

Testing

  • Python: 740+ tests (pytest tests/), coverage enforced at 86%+ in CI
  • Rust: formatparse-core and formatparse-pyo3 tests (cargo test -p formatparse-core --all-targets)
export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
pytest tests/

License

MIT License — see LICENSE.

Credits

Based on the parse library by Richard Jones.

Metadata

Release files for formatparse 0.8.7

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

Source distribution (sdist)

Source distribution for formatparse 0.8.7
File Size Uploaded
formatparse-0.8.7.tar.gz 103.6 kB Details

Release files / formatparse-0.8.7.tar.gz

Download URL formatparse-0.8.7.tar.gz
Size 103.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a427d4e0771e3a032324e8c0b4bd3608d84b08685b580446bede7d2a733191df
BLAKE2b-256 checksum
How to use checksums
5c0821439da10b6570662d481514c20ead0ad4cce32f54f917be868b740a8bb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14
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