Skip to main content

Python binding for vitaut/zmij float formatting library

Project description

pyzmij

Python C extension for fast formatting of Python float values using vitaut/zmij.

API

import pyzmij

# Format a single float
s = pyzmij.format_finite(3.141592653589793)

# General formatter (optional JSON compatibility)
s2 = pyzmij.format(1.0, json_compatible=True)  # "1.0"

# Batch formatter (returns list[str])
items = pyzmij.format_many([1.0, -0.0, 3.14], json_compatible=True)

# Batch formatter (returns one joined string)
line = pyzmij.format_join([1.0, -0.0, 3.14], sep=",", json_compatible=True)

# Batch format and get total output length (sequence input)
total_len = pyzmij.format_many_len([1.0, 2.0, 3.0])

Practical Use Cases

import pyzmij

values = [1.0, -0.0, 3.141592653589793]

# 1) JSON payload fragment
json_numbers = "[" + ",".join(pyzmij.format_many(values, json_compatible=True)) + "]"

# 2) CSV row
csv_row = pyzmij.format_join(values, sep=",")

# 3) Structured logs
log_text = "sensor_values=" + pyzmij.format_join(values, sep=",", json_compatible=True)

# 4) Direct stream write (file/socket-like object with write(str))
with open("out.txt", "w", encoding="utf-8") as f:
    pyzmij.write_many(f, values, sep=",", end="\n", json_compatible=True)

pyzmij is applied only when you explicitly call pyzmij.format* APIs. This package intentionally does not replace Python's built-in print() behavior.

Semantics

format_finite(x) returns the shortest correctly-rounded decimal representation for finite Python float values. In particular, integer-valued floats may not include a trailing .0 (e.g. 1.0 may format as "1").

Input contract:

  • format(x, *, json_compatible=False, allow_non_finite=False) accepts a Python float.
  • format_finite(x) accepts a Python float only (rejects int, str, None, NaN, and Inf).
  • format_many(seq, *, json_compatible=False, allow_non_finite=False) returns list[str].
  • format_join(seq, *, sep=",", json_compatible=False, allow_non_finite=False) returns str.
  • format_many_len(seq) accepts a sequence (for example list or tuple) whose items are all float.
  • format_many_len returns only total formatted length (int).
  • write_many(file, seq, *, sep=",", end="\n", json_compatible=False, allow_non_finite=False) writes once via file.write(...).
  • bench_format_many(seq) remains available as a compatibility alias.

json_compatible means "match JSON float text conventions":

  • finite integer-looking values keep a decimal point (1.0 -> "1.0")
  • negative zero keeps its sign (-0.0 -> "-0.0")
  • if allow_non_finite=True, non-finite values use JSON tokens (NaN, Infinity, -Infinity)

Building

uv pip install -e .

This package vendors its vitaut/zmij dependency under third_party/ (no git submodule required).

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

pyzmij-0.1.0.tar.gz (49.3 kB view details)

Uploaded Source

Built Distributions

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

pyzmij-0.1.0-cp313-cp313-win_amd64.whl (24.9 kB view details)

Uploaded CPython 3.13Windows x86-64

pyzmij-0.1.0-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (54.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

pyzmij-0.1.0-cp313-cp313-macosx_11_0_arm64.whl (22.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pyzmij-0.1.0-cp312-cp312-win_amd64.whl (24.9 kB view details)

Uploaded CPython 3.12Windows x86-64

pyzmij-0.1.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (54.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

pyzmij-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (22.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyzmij-0.1.0-cp311-cp311-win_amd64.whl (24.9 kB view details)

Uploaded CPython 3.11Windows x86-64

pyzmij-0.1.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (53.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

pyzmij-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (22.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyzmij-0.1.0-cp310-cp310-win_amd64.whl (24.9 kB view details)

Uploaded CPython 3.10Windows x86-64

pyzmij-0.1.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (52.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

pyzmij-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (22.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file pyzmij-0.1.0.tar.gz.

File metadata

  • Download URL: pyzmij-0.1.0.tar.gz
  • Upload date:
  • Size: 49.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyzmij-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b08071b8b5076f6da68e77be9276ed8badf749c732ce48fea2db42540324e85b
MD5 a6b90431cd19e82a68f9d87053f9cfed
BLAKE2b-256 a9536874b4c61d491f58c41b713571d2ee627380a0a344aacea7e47f4dde693b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyzmij-0.1.0.tar.gz:

Publisher: publish-pyzmij.yml on mp0rta/pyzmij

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyzmij-0.1.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pyzmij-0.1.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 24.9 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyzmij-0.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3e12f315354821f22c2df76b3261611d2690ef007d812f4289b2985633a85b09
MD5 2b54504bcf9516050faccd6ea4f3738e
BLAKE2b-256 bd2ac377c7194f006964ead5f22348129b864da386344fc5c810e8f0e1fe243a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyzmij-0.1.0-cp313-cp313-win_amd64.whl:

Publisher: publish-pyzmij.yml on mp0rta/pyzmij

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyzmij-0.1.0-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyzmij-0.1.0-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aa514b7d1b6eadc9a064f819326dbe469b0a673343c24b06f78cbbd50797d5fe
MD5 139fa2c03d101fd86750eebb6dd75699
BLAKE2b-256 d5675c7f3da8744ebdbf7037069e50bf71866e56a1f4755f9713641992fade5b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyzmij-0.1.0-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-pyzmij.yml on mp0rta/pyzmij

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyzmij-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyzmij-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9c186692e36124446c66fa39297a6f80138c20016925cddd99af0d20e6c4d357
MD5 e58eeb8fb04f96ab365d99d05a1641e2
BLAKE2b-256 8276c3b4eab55293d859bd3b3312cb4e21e381be2df48017314408e3a3cc16df

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyzmij-0.1.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: publish-pyzmij.yml on mp0rta/pyzmij

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyzmij-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pyzmij-0.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 24.9 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyzmij-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 cd7dcc06de7c62e13ee9b12a222f8a0c02ecba1a99fcde1feb927c9e3b0d0bf7
MD5 4b95c9c45a5e82ea14d1071fe7c514c3
BLAKE2b-256 b134587700cee10e110604b20fe60fde0e3571908ab2736aa1816618f919b2e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyzmij-0.1.0-cp312-cp312-win_amd64.whl:

Publisher: publish-pyzmij.yml on mp0rta/pyzmij

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyzmij-0.1.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyzmij-0.1.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bf9bea5d730bbabb442153d7f982d6dc319f8a5a575d58064dcf9c231ffd2994
MD5 22074e3ebc9e6dd64b66610e78b1bb49
BLAKE2b-256 f2ba67e569db5b29ff619b5bab9d88e032331c414d241d079994b0410a039cc8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyzmij-0.1.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-pyzmij.yml on mp0rta/pyzmij

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyzmij-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyzmij-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 33237c780ef88a7f9ca32e5080bb641e01b7c5cc942bb36d66bb38874d0b029e
MD5 b3e6eec19d6e8f95ddcbc700949ce7df
BLAKE2b-256 2d30aedab507556dbef555adb84b0b6bf0bbf611a55298d0fbcd87222a46435a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyzmij-0.1.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish-pyzmij.yml on mp0rta/pyzmij

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyzmij-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pyzmij-0.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 24.9 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyzmij-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 861db6d62cd74a4d65621bccd0439ef11292d35b241fb1da1c7b42015f4b22c3
MD5 e8806fdc0eb740da3822b50fea1cf5d7
BLAKE2b-256 4abe8fdffbc48e1dae3ab419f4729cd90ae21fdaaf277c6c67ca1712449f073b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyzmij-0.1.0-cp311-cp311-win_amd64.whl:

Publisher: publish-pyzmij.yml on mp0rta/pyzmij

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyzmij-0.1.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyzmij-0.1.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ed2e87e202528697fa8813677e1de97dbf11ba99dc6377e0fae2107f6aac209e
MD5 4ae4cc71988fecd539d7a7970a21b458
BLAKE2b-256 9f8a797024d00321dd9d48d8b7fad2f9351c3133cc35d0af341c8a141ed20dc5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyzmij-0.1.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-pyzmij.yml on mp0rta/pyzmij

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyzmij-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyzmij-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 81664c8f19b0e793bc8589f9d52e56726cf451d6bccf6e4304c3a415ce4032ec
MD5 6d971da810cd51e68ddfc360f3b5f352
BLAKE2b-256 043a0fadf89c3f5ceb106695de8591837a3dce25cfe217087f8e3d802a9da675

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyzmij-0.1.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: publish-pyzmij.yml on mp0rta/pyzmij

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyzmij-0.1.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pyzmij-0.1.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 24.9 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyzmij-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3700fc8e8b3275076d2ba55614579d44a7f28d732efa0edebfda3dd4fd265e1b
MD5 35cfd28fd7b6d5fe8ab4f6da4e72e4ba
BLAKE2b-256 8cfd13bb053ce57eb749d0d35c064855d6350a36dcf41966c06567996724c784

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyzmij-0.1.0-cp310-cp310-win_amd64.whl:

Publisher: publish-pyzmij.yml on mp0rta/pyzmij

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyzmij-0.1.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyzmij-0.1.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d9ebcc10d4e97bb14f958fd86d141ef8ab80e9fbb77b5d3480a6313c1c07e4de
MD5 8333fea3e51d16b6d9ec5c8d84868106
BLAKE2b-256 cfd0d4a2bc43f86ca0a192e786453d030e04f97452818dccd8b1c04a1535932c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyzmij-0.1.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-pyzmij.yml on mp0rta/pyzmij

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyzmij-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyzmij-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7d45fc8f702b46d3fa8cfbd8e8e450ae0c45814ac4a9d66d6907cca7a8ca2102
MD5 bd6f34ba2166e09ebfad99b74f999398
BLAKE2b-256 1bb727a319e5c95ad10ba2828665c2f434c6e25468581a983d06e3ba49396cd9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyzmij-0.1.0-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: publish-pyzmij.yml on mp0rta/pyzmij

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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