Metadata-Version: 2.4
Name: pintrs
Version: 0.4.7
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Rust
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Typing :: Typed
Requires-Dist: numpy>=1.24 ; extra == 'all'
Requires-Dist: babel>=2.12 ; extra == 'all'
Requires-Dist: pandas>=2.0 ; extra == 'all'
Requires-Dist: babel>=2.12 ; extra == 'babel'
Requires-Dist: numpy>=1.24 ; extra == 'numpy'
Requires-Dist: pandas>=2.0 ; extra == 'pandas'
Requires-Dist: numpy>=1.24 ; extra == 'pandas'
Provides-Extra: all
Provides-Extra: babel
Provides-Extra: numpy
Provides-Extra: pandas
License-File: LICENSE
Summary: Fast Rust-based Python extension for physical unit manipulation
Keywords: units,physics,quantities,conversion,pint
Author-email: Thomas Nowak <thomas@thomasnowak.net>
License-Expression: Apache-2.0
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM

# pintrs

If you like [`pint`](https://pint.readthedocs.io/) but wish it were faster, `pintrs` is for you. Same API, same workflow, but with the heavy lifting done in Rust.

## Installation

```bash
pip install pintrs
```

## Migration

`pintrs` is designed as a drop-in replacement. Swap your dependency, update your imports, and you're done.

```diff
- pint
+ pintrs
```

```diff
- from pint import UnitRegistry
+ from pintrs import UnitRegistry

ureg = UnitRegistry()
distance = 5 * ureg.kilometer
time = 2 * ureg.hour
speed = (distance / time).to("m/s")
```

## How much faster?

Measured on 2026-09-15 on an Intel Core i5-12600K (Linux x86_64), with Python 3.13.5,
pintrs 0.4.6 built in release mode, pint 0.26.1, and NumPy 2.4.3.
Results are the best of five runs of 10,000 operations with warm unit caches;
registry construction and array setup are excluded. Timings vary by machine
and dependency versions. Run `python examples/benchmark.py` to reproduce.

**Scalar operations:**

| Operation | pintrs | pint | Speedup |
|---|--:|--:|--:|
| Quantity from string (`"9.81 m/s**2"`) | 0.46 us | 66.86 us | **146.3x** |
| Conversion (km → m) | 0.28 us | 8.76 us | **31.0x** |
| Multiply by scalar | 0.27 us | 6.27 us | **23.2x** |
| Quantity creation | 0.34 us | 4.35 us | **12.7x** |
| To base units | 0.25 us | 7.26 us | **28.9x** |
| Addition (same units) | 0.66 us | 5.64 us | **8.5x** |
| Multiply quantities | 0.72 us | 6.02 us | **8.4x** |
| Parse units (`"kg * m / s ** 2"`) | 0.36 us | 2.14 us | **6.0x** |

**NumPy arrays (1000 float64 elements, created with `ureg.Quantity`):**

| Operation | pintrs | pint | Speedup |
|---|--:|--:|--:|
| Conversion (m → km) | 1.11 us | 9.40 us | **8.5x** |
| Sum | 1.10 us | 20.82 us | **19.0x** |
| Create | 1.07 us | 4.34 us | **4.0x** |
| Multiply by scalar | 1.25 us | 7.32 us | **5.8x** |
| Addition | 1.76 us | 6.26 us | **3.6x** |
| Temperature conversion (°C → K) | 1.77 us | 16.00 us | **9.0x** |
| Logarithmic conversion (dBm → W) | 10.21 us | 23.12 us | **2.3x** |

## Something not working?

If you hit a compatibility issue or something behaves differently from `pint`, please [open an issue](https://github.com/BioDisCo/pintrs/issues). Migration should be painless, and if it isn't, we want to know about it.

