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.6.tar.gz (102.9 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: formatparse-0.8.6.tar.gz
  • Upload date:
  • Size: 102.9 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.6.tar.gz
Algorithm Hash digest
SHA256 438265f933309713b8925e8f7c31e409a83cb3d1c3aecc4835d49e049f2ef21a
MD5 7f4dd5e43428dab177fe130b2b05a748
BLAKE2b-256 3a374275580e5f8f1eacbc0242f8ddc897bc3d58917664102b9b368accfe0fce

See more details on using hashes here.

Release history Release notifications | RSS feed

0.8.7

1 file

This release

0.8.6 This release

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