Numerary is a Python library that provides a set of type-hinting protocols (e.g., `Integer`, `Float`, `Real`, `Complex`, `Number`) designed for more precise and robust type-checking of numeric types in Python. It is currently at version 0.4.4 and is under active development with frequent, smaller updates.
Install & Compatibility
Where this runs
tested against v0.4.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 27MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 2.0s · import 0.000s · 27MB
25MB installed
● package 25MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
from numerary import Integer
from numerary import IntegralLike
from numerary import RealLike
This quickstart demonstrates how to use `numerary` protocols for runtime type checking with `isinstance` and static type hints. The protocols allow distinguishing between different categories of numbers.
from numerary import Integer, Float, Real, Number
def process_number(n: Number) -> str:
if isinstance(n, Integer):
return f"It's an integer: {n} (type: {type(n).__name__})"
elif isinstance(n, Float):
return f"It's a float: {n} (type: {type(n).__name__})"
elif isinstance(n, Real):
return f"It's a real number: {n} (type: {type(n).__name__})"
else:
return f"It's a generic number: {n} (type: {type(n).__name__})"
print(process_number(5))
print(process_number(5.0))
print(process_number(3 + 4j))
print(process_number(10.5))
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.