Python bindings for faup-rs Rust library
Actively maintained. Last release 7 days ago, commits in 21 of the last 26 weeks. A safe choice.
$
pip install pyfaup-rspyfaup: Fast URL Parser for Python (Rust-Powered)
pyfaup is a high-performance URL parsing library for Python, built in Rust using PyO3. It provides a modern, type-safe, and efficient way to parse URLs, with backward compatibility for the legacy Faup C project's API.
Features
- Fast and Efficient: Powered by Rust for maximum performance.
- Modern API: Direct access to URL components via the
Urlclass. - Backward Compatibility:
FaupCompatclass mimics the original Faup Python API. - Comprehensive Parsing: Supports schemes, credentials, hosts, ports, paths, queries, and fragments.
- Error Handling: Clear and informative error messages.
Installation
Prerequisites
- Python 3.8+
- Rust toolchain (for building from source)
Install from PyPI
pip install pyfaup-rs
Install from Source
- Clone the repository:
git clone https://github.com/ail-project/faup-rs.git cd faup-rs/python - Install using
maturin:pip install maturin maturin develop
Usage
Using the Url Class
The Url class provides direct access to all URL components:
from pyfaup import Url
url = Url("https://user:pass@sub.example.com:8080/path?query=value#fragment")
print(url.scheme) # "https"
print(url.username) # "user"
print(url.host) # "sub.example.com"
print(url.port) # 8080
Using the FaupCompat Class
The FaupCompat class provides a compatibility layer for the original FAUP API: