High-Throughput Native Acceleration for ISO 20022#
pain001-fast is an optional, high-throughput native acceleration core written in Rust with PyO3 bindings. Designed for corporate treasury backbones, high-frequency clearing hubs, and payment service providers, it offloads CPU-intensive validation loops from the Python Global Interpreter Lock (GIL) to parallel multi-core hardware.
Status: experimental. Version 0.0.91 joins the pain001 suite in lockstep. Source and native wheels are distributed through GitHub Releases; the package is not published on PyPI or crates.io.
When the pain001_fast module is importable, pain001 core uses it for IBAN, BIC, and character set validation without any configuration or API changes; when it is not, pain001 uses its own Python routines.
Performance Characteristics#
Micro-benchmarked by the project on Apple Silicon (M-series), release build; these figures have not been reproduced independently:
| Benchmark Scenario | Standard Pure Python | pain001-fast (Rust) | Speedup Factor |
|---|---|---|---|
| IBAN Checksum (Mod-97) | 1,850 ns / op | 22 ns / op | ~84× faster |
| BIC Structural Check | 1,200 ns / op | 14 ns / op | ~85× faster |
| SWIFT-X Diacritic Sanitization | 2,100 ns / op | 115 ns / op | ~18× faster |
| Batch Analysis (10,000 orders) | 3,450 ms | 165 ms | > 60,000 tx/sec |
| Heap Memory Overhead | ~12 objects / tx | 0 heap allocations | Zero Allocation |
Core Capabilities#
1. Zero-Allocation Mod-97 Engine
Implements ISO 7064 mod-97-10 check digit verification directly in CPU registers. By streaming ASCII character byte arithmetic through an inlined modular accumulator, pain001-fast completely eliminates the big integer string heap allocations that constrain standard interpreter runtimes.
2. Regex-Free Structural BIC Parsing
Validates 8 and 11 character ISO 9362 Business Identifier Codes using inlined byte checks and branchless lookup tables against the official ISO 3166-1 alpha-2 country registry.
3. NFKD Character Set Sanitizer
Fast Unicode normalization decomposes accented characters (such as é to e, ü to u) and replaces unpermitted characters with compliant ASCII delimiters in sub-microsecond time.
4. Parallel Multi-Core Batch Analyzer
Leverages Rayon work-stealing thread pools to validate thousands of transaction records across all available CPU cores simultaneously:
- Calculates per-currency control sums and counts.
- Builds SHA-256 / composite collision fingerprints to detect duplicate payments in memory.
- Returns comprehensive structured diagnostic reports with sub-50ms p99 latency.
Python API Quick Start#
# Sub-25ns IBAN validation
assert is True
# Structural BIC verification
assert is True
# High-throughput batch validation across CPU cores
=
=
assert is True
assert == 1
assert == 1250.00
Architectural Guarantee & Fallback#
pain001-fast exposes standalone validation helpers. Import them explicitly; installing the extension does not activate it in the core library. Use the core library for payment XML generation and validation, including environments such as Pyodide where this native extension is unavailable.