Skip to main content

Statically typed units

Project description

u

Statically typed units.

Quickstart

# Type safe assignments
duration: u.Duration = u.seconds(5)  # Ok
distance: u.Distance = u.amperes(5)  # Type checking error

# Type safe math
print(u.seconds(120) + u.minutes(3))  # Ok
print(u.seconds(120) + u.amperes(3))  # Type checking error

# Type safe compound units (with some caveats)
speed: u.Div[u.Distance, u.Duration] = u.km(5) / u.hours(1)  # Ok

# Reusable prefixes
print(u.bytes(1000) == u.mega(u.bytes)(1))

# Define your own Quantities and Units
class Tastiness(u.Quantity):
    pass

mmm = u.Unit[Tastiness](symbol='mmm', multiplier=1)
yum = u.Unit[Tastiness]('yum', 10)

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

u-0.1.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

u-0.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file u-0.1.tar.gz.

File metadata

  • Download URL: u-0.1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.2

File hashes

Hashes for u-0.1.tar.gz
Algorithm Hash digest
SHA256 dbdbceb210a71ccc722d2689f2b270376fdd278e6f38a664a930178f4e21eaba
MD5 19927ebbf013f158cc4a2d3be3b23067
BLAKE2b-256 39dadf83b3a43f946bfde20dedf1095f8fc9584340ebb02082c87bd457369e01

See more details on using hashes here.

File details

Details for the file u-0.1-py3-none-any.whl.

File metadata

  • Download URL: u-0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.2

File hashes

Hashes for u-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 028526128cb7b84c2f5f0dce7ccacca34dea99950b9ec09f24faa62fc252ecb8
MD5 1ba6cf720d60e5b852d8a67b5aa539e1
BLAKE2b-256 7e610f2f440284b690f88effa82ad9dfe5ad00919385bcb2ceb1c373da9bae62

See more details on using hashes here.

Supported by

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