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.

Download files

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

Source Distribution

formatparse-0.8.7.tar.gz (103.6 kB view details)

Uploaded Source

File details

Details for the file formatparse-0.8.7.tar.gz.

File metadata

  • Download URL: formatparse-0.8.7.tar.gz
  • Upload date:
  • Size: 103.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for formatparse-0.8.7.tar.gz
Algorithm Hash digest
SHA256 a427d4e0771e3a032324e8c0b4bd3608d84b08685b580446bede7d2a733191df
MD5 90c51e45ae5cfd40cd7a32cb6e0cd5e3
BLAKE2b-256 5c0821439da10b6570662d481514c20ead0ad4cce32f54f917be868b740a8bb6

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.8.7 This release

1 file

0.8.6

1 file

0.8.5

1 file

0.8.4

1 file

0.8.3

1 file

0.8.2

1 file

0.8.1

1 file

0.8.0

1 file

0.7.0

1 file

0.6.1

33 files

0.6.0

33 files

0.5.3

33 files

0.5.2

29 files

0.5.1

24 files

0.4.2

16 files

0.4.1

16 files

0.4.0

16 files

0.3.0

16 files

0.2.0

16 files

0.1.0

16 files

Supported by

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