Computational number theory. Pure Python. Zero dependencies. Unreasonably fast.
Installation
pip install numthy
Or just drop numthy.py into your project.
Quick Start
import numthy as nt
# Primality
nt.is_prime(2**89 - 1) # True
# Factorization (SIQS handles 50+ digits)
nt.prime_factors(2**128 + 1) # (59649589127497217, 5704689200685129054721)
# Prime counting
nt.count_primes(10**9) # 50847534
# Discrete log
nt.discrete_log(1000, 3, 65537) # 50921 (i.e., 1000 ≡ 3^50921 mod 65537)
# Diophantine equations
# Solve 2x² + 3xy - 3y² + 7x - 10y - 24 = 0
solutions = nt.conic(2, 3, -3, 7, -10, -24)
next(solutions) # (8, 10)
next(solutions) # (376, -174)
next(solutions) # (17304, 25218)
Demo
Try NumThy in the browser: ini.github.io/numthy/demo
Documentation
See API.md for the full reference.
Under The Hood
One file, with everything implemented from scratch. Simple API, with heavy-duty algorithms under the hood:
- Extra-strong variant of the Baillie-PSW primality test
- Lagarias-Miller-Odlyzko (LMO) algorithm for prime counting, generalized to sums over primes of any arbitrary completely multiplicative function
- Two-stage Lenstra's ECM factorization with Montgomery curves and Suyama parametrization
- Self-initializing quadratic sieve (SIQS) with triple-large-prime variation
- Cantor-Zassenhaus → Hensel lifting → Chinese Remainder Theorem pipeline for finding modular roots of polynomials
- Adleman-Manders-Miller algorithm for general n-th roots over finite fields
- General solver for all binary quadratic Diophantine equations (ax² + bxy + cy² + dx + ey + f = 0)
- Lenstra–Lenstra–Lovász lattice basis reduction algorithm with automatic precision escalation
- Jochemsz-May generalization of Coppersmith's method for multivariate polynomials with any number of variables
Requirements
Python 3.10+
That's it.
License
Metadata
Release files for numthy 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| numthy-0.2.1.tar.gz | 109.4 kB | Without provenance | Details for numthy-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| numthy-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for numthy-0.2.1-py3-none-any.whl |
Total release size: 176.0 kB
Release files / numthy-0.2.1.tar.gz
| Download URL | numthy-0.2.1.tar.gz |
|---|---|
| Size | 109.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c2b4923c921f08c3ba22089e7b428d7370557acdbbb361e0e9fcb7df554bb74e
|
|
BLAKE2b-256 checksum How to use checksums |
9a88cea069fdc7ec2afc52bb4a122288436a012161f9f6a1aa3e63f661b2ff1c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / numthy-0.2.1-py3-none-any.whl
| Download URL | numthy-0.2.1-py3-none-any.whl |
|---|---|
| Size | 66.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
025da604b8e68ac7e118d7d36e45a1d8d515f1c9f3d929e44b04c815dddae1db
|
|
BLAKE2b-256 checksum How to use checksums |
79f0eaf079a3b5535b309822cae61cb36ef3461c55ee84472457b9f174ffe033
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Security for numthy 0.2.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.