Skip to main content

FaSt_PUC

FaSt_PUC is a Python package that provides pretty unit conversion with automatic SI prefix selection. It intelligently formats numbers with appropriate metric prefixes (like k, M, G, µ, n, etc.) to make them more readable.

Features

  • Automatic selection of SI prefixes from atto (a) to peta (P)
  • Support for custom unit strings
  • Special formatting options for percentages and decibels
  • File name compatible output
  • Configurable precision
  • Support for NumPy arrays
  • No external dependencies except NumPy

Installation

Install using pip:

pip install fast-puc

Basic Usage

Import the package and call the main function:

from fast_puc import puc

# Basic number formatting
puc(1.0001)         # "1"
puc(1.0001, "m")    # "1m"
puc(0.991e-6, "s")  # "991ns"
puc(1030e-9, "m")   # "1.03µm"
puc(999.999, "W")   # "1kW"

# Vectorized input returns a list of formatted values
puc([900e-6, 1000e-6, 1100e-6], "m")  # ["900µm", "1mm", "1.1mm"]
puc(np.array([1e-3, 2e-3]), "W")       # ["1mW", "2mW"]

Advanced Features

Custom Separators and Special Formats

# Custom separators
puc(1.0001, " m")   # "1 m"    # with space separator
puc(1.0001, "_m")   # "1_m"    # with underscore separator

# Special formats
puc(0.911, "%")     # "91.1%"  # convert to percent
puc(1001, "dB")     # "30dB"   # convert to dB
puc(1030e-9, "!m")  # "1p03um" # file name compatible with special character !

Precision Control

puc(1.2345, "m", precision=2)      # "1.2m"
puc(0.012345, "m", precision=2)    # "12mm"
puc(0.000123456, "m", precision=5) # "123460nm"

Advanced Options

The puc function accepts several optional parameters:

puc(value,               # Number to format (float or numpy array)
    unit="",            # Unit string with optional modifiers
    precision=3,        # Number of significant digits
    verbose=False,      # Return additional formatting info
    filecompatible=False) # Make output safe for filenames

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

Licensed under MIT License. See LICENSE for details.

Author

Written by Fabian Stutzki (fast@fast-apps.de)

For more information, visit https://www.fast-apps.de

Metadata

Release files for fast-puc 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fast-puc 0.3.0
File Size Uploaded
fast_puc-0.3.0.tar.gz 15.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fast-puc 0.3.0
File Interpreter ABI Platform
fast_puc-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.0 kB

Release files / fast_puc-0.3.0.tar.gz

Download URL fast_puc-0.3.0.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4f4411fb5e6ed68579bcac45c3a8eecf27ab44f140715c9c3028249d1894e5ca
BLAKE2b-256 checksum
How to use checksums
86756e2afcadfca3f123d61cf7e343962272578a89c1e93845327820e62a2702
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release files / fast_puc-0.3.0-py3-none-any.whl

Download URL fast_puc-0.3.0-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8987b8c4537fd2cff1074373a29813c654fe01dda6e3803241788e4a9a093d7
BLAKE2b-256 checksum
How to use checksums
e37fcfe117d93c7a9a600d2b145f1497a5178f7b04757043c8095930a0c96ce0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page