Skip to main content

Fast Rust-based Python extension for physical unit manipulation

Project description

pintrs

If you like pint but wish it were faster, pintrs is for you. Same API, same workflow, but with the heavy lifting done in Rust.

Installation

pip install pintrs

Migration

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

- pint
+ pintrs
- 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?

Here's what you get for that one-line change. Measured with Python 3.12; run python examples/benchmark.py to reproduce.

Operation pintrs pint Speedup
Quantity creation 0.37 us 3.33 us 9x
Parse string ("9.81 m/s**2") 0.55 us 50.21 us 91x
Conversion (km -> m) 0.94 us 7.43 us 8x
Conversion (km/h -> m/s) 1.71 us 13.30 us 8x
Addition (same units) 0.34 us 4.64 us 14x
Addition (compatible units) 1.03 us 11.56 us 11x
Multiply by scalar 0.25 us 5.31 us 21x
Multiply quantities 0.38 us 5.01 us 13x
Comparison (>) 0.12 us 1.16 us 10x
To base units 0.37 us 6.43 us 17x
Parse units ("kg * m / s ** 2") 0.26 us 38.85 us 152x
String formatting 0.44 us 7.20 us 16x

Something not working?

If you hit a compatibility issue or something behaves differently from pint, please open an issue. Migration should be painless, and if it isn't, we want to know about it.

Project details


Download files

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

Source Distribution

pintrs-0.2.5.tar.gz (134.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pintrs-0.2.5-cp313-cp313-win_amd64.whl (415.3 kB view details)

Uploaded CPython 3.13Windows x86-64

pintrs-0.2.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (566.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pintrs-0.2.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (551.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

pintrs-0.2.5-cp313-cp313-macosx_11_0_arm64.whl (507.9 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pintrs-0.2.5-cp313-cp313-macosx_10_12_x86_64.whl (531.5 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

pintrs-0.2.5-cp312-cp312-win_amd64.whl (415.7 kB view details)

Uploaded CPython 3.12Windows x86-64

pintrs-0.2.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (567.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pintrs-0.2.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (551.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

pintrs-0.2.5-cp312-cp312-macosx_11_0_arm64.whl (508.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pintrs-0.2.5-cp312-cp312-macosx_10_12_x86_64.whl (531.9 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

File details

Details for the file pintrs-0.2.5.tar.gz.

File metadata

  • Download URL: pintrs-0.2.5.tar.gz
  • Upload date:
  • Size: 134.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for pintrs-0.2.5.tar.gz
Algorithm Hash digest
SHA256 ea4d79d3fab5ba3e771ab7324e6604b532cff9a8037a74481a03537750361571
MD5 4fbfc981d2b1f986de5a9605ae73cc42
BLAKE2b-256 2629020966103872704c9657f7e461227bf80233cff4fecc8a603a516ab406fd

See more details on using hashes here.

File details

Details for the file pintrs-0.2.5-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pintrs-0.2.5-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 415.3 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for pintrs-0.2.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 136806ddcbdd6d87f0477fdabc74a941ee429bf40c5fc1970df32eaaa3678608
MD5 f87c76617b30465d5fd127aa17971b4e
BLAKE2b-256 09529c8e69f63117ca846cbc07ecaa02cebd31b5d8eed15a3a8e00ea25f761be

See more details on using hashes here.

File details

Details for the file pintrs-0.2.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pintrs-0.2.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8fdddc4b946d6a1d02fec59c956b208fbbda0a03a9143503252e981c99401df6
MD5 f92cb5ef04618f748d5067b45b938ef7
BLAKE2b-256 87710abccbd155e73f6d0ccfbc036dec6c49ad342172b70040b537d6cf77264d

See more details on using hashes here.

File details

Details for the file pintrs-0.2.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pintrs-0.2.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 33bcc24df75a9965c1324877b4e35251d6d4107fd275a919ae7dfdb3d9f29cad
MD5 d338e8171ae8feb1ffcc63f7791c2e91
BLAKE2b-256 1e0061e6174a6edcd8c19a8d402b44eaa452554cd2a1ca8ef3810743f2505a00

See more details on using hashes here.

File details

Details for the file pintrs-0.2.5-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pintrs-0.2.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9b7480cb4bc8089c4eedcfe4896a2d86d43c2919abba489a2edb150a1aa0b561
MD5 aea196bfa167220e129d1d7abf5f9224
BLAKE2b-256 ae372e7aca42ba577df4d0ee0abb67a6edec5d6cef550a444ccd1522a192ca92

See more details on using hashes here.

File details

Details for the file pintrs-0.2.5-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pintrs-0.2.5-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e258e20ffab85631211349ec7b35712a760a9a49f562fbf5d41af18d4228f420
MD5 5b5f6f5e43272617fe152d58fe524e49
BLAKE2b-256 feb230aac312fbdde4e78c26ffc5e470e1a1a9b0b1815447d1392124e082c48b

See more details on using hashes here.

File details

Details for the file pintrs-0.2.5-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pintrs-0.2.5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 415.7 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for pintrs-0.2.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 94019310d508b94fc453fb2f68d08ec756c776615f9e6886aa87a5810cd94e63
MD5 c15eddda40304b25f5cc930c28dea8a6
BLAKE2b-256 84fb456c46991893524d16eb9cbb1300854986f408607405f5c36bd4eefbc62e

See more details on using hashes here.

File details

Details for the file pintrs-0.2.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pintrs-0.2.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a23e04e501ee620e462d83cf47f3a9ba04ade9034d77ffae466ac447b4bdb477
MD5 0be2c43cc5f70507dd47502da24b3dc2
BLAKE2b-256 641fc9ed32f583e5d4a3d2b79ea0cf8db2938c23522da5a43bf8db360175f300

See more details on using hashes here.

File details

Details for the file pintrs-0.2.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pintrs-0.2.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a009813c4a8fa6ec1c603930eda780fd228fdf70bef0f484f7605b0e658b9d4a
MD5 079ff7f7e412f1da69b386a5f3efb8b1
BLAKE2b-256 6ebe32851535178f2f46c910a16580a83744fc1092a38eaef5e66ed523bf3361

See more details on using hashes here.

File details

Details for the file pintrs-0.2.5-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pintrs-0.2.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f2b7bd92aa2c324b31092052079ce46b89f90861728a747674ad53cef68105a4
MD5 7bd02dec1a97622accc132286e3ed26b
BLAKE2b-256 e471ef8ef6ac709e12098f9b80e3e33aca170769d0ab84dd40dfd129a38132ba

See more details on using hashes here.

File details

Details for the file pintrs-0.2.5-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pintrs-0.2.5-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 524a8490484b48bcdffec82f79b9cb2e35e47634926b95819d55b39998a84012
MD5 ca2f003be5daa87e1d318c4119772899
BLAKE2b-256 60b9acd49485e50bd3e08cb91856dcc881651ec116a258263f501ee77daf25a2

See more details on using hashes here.

Supported by

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