Infinite number sequences
Project description
Lazy, immutable, infinite numeric sequences for Python.
countably lets you describe sequences declaratively, the way you’d write them on paper, and evaluate them on demand:
from countably import count, constant
triangular = count() * (count() + 1) // 2 # 0, 1, 3, 6, 10, ...
powers_of_two = 2 ** count() # 1, 2, 4, 8, 16, ...
every_third = count()[2::3] # 2, 5, 8, 11, ...
The primitives are just constant and count. Arithmetic, comparisons, slicing, and element-wise maximum / minimum build everything else. Plain numbers are coerced automatically, so 3 + 5 * count() is equivalent to constant(3) + constant(5) * count().
Highlights
Lazy – elements are computed only on access, with a per-instance 100-item LRU cache for random access. Iteration walks the inputs directly, bypassing the cache.
Immutable – every operation produces a new sequence; nothing is mutated.
Iterable, not iterator – iter(seq) starts fresh every time.
Slices are lazy too – seq[2::3] stays infinite, seq[2:10] is finite with a real len(). Arithmetic between sequences uses the shorter length.
Round / floor / ceil / trunc are supported through the standard Python protocols (math.floor(seq), round(seq)).
Comparisons (<, <=, >, >=) return sequences of booleans, which are numbers in the same world.
See doc/quick-start.rst for usage including a Fibonacci one-liner.
Install
pip install countably
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file countably-2026.5.16.79282rc1.tar.gz.
File metadata
- Download URL: countably-2026.5.16.79282rc1.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
191d344dd2273da833e4a57114a3ef6483271b121386d05fe075dd01809f374b
|
|
| MD5 |
4e88105ed12009aa5c6e87facb2f193e
|
|
| BLAKE2b-256 |
376127cbdbf8a07722b6a13102bba1e6cba498a3ed16bf76d48346c2b5e752e6
|
Provenance
The following attestation bundles were made for countably-2026.5.16.79282rc1.tar.gz:
Publisher:
release.yml on moshez/countably
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
countably-2026.5.16.79282rc1.tar.gz -
Subject digest:
191d344dd2273da833e4a57114a3ef6483271b121386d05fe075dd01809f374b - Sigstore transparency entry: 1554655361
- Sigstore integration time:
-
Permalink:
moshez/countably@b950a0abe62b086b7a85959ab04fb7aa3f2b7485 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/moshez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b950a0abe62b086b7a85959ab04fb7aa3f2b7485 -
Trigger Event:
push
-
Statement type:
File details
Details for the file countably-2026.5.16.79282rc1-py3-none-any.whl.
File metadata
- Download URL: countably-2026.5.16.79282rc1-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf174292f830fba25b980c3688440b7ce1f103ae974e393d0e850b6600bb2610
|
|
| MD5 |
27e60aca91caa0b1f55a3594bfd21273
|
|
| BLAKE2b-256 |
d1c12d7a45d0a57e18d2554f3dc20f8fe1e4ca99057200c8e2ee3b52f0e78e48
|
Provenance
The following attestation bundles were made for countably-2026.5.16.79282rc1-py3-none-any.whl:
Publisher:
release.yml on moshez/countably
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
countably-2026.5.16.79282rc1-py3-none-any.whl -
Subject digest:
bf174292f830fba25b980c3688440b7ce1f103ae974e393d0e850b6600bb2610 - Sigstore transparency entry: 1554655366
- Sigstore integration time:
-
Permalink:
moshez/countably@b950a0abe62b086b7a85959ab04fb7aa3f2b7485 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/moshez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b950a0abe62b086b7a85959ab04fb7aa3f2b7485 -
Trigger Event:
push
-
Statement type: