Skip to main content

Infinite number sequences

Project description

PyPI version Supported Python versions Documentation Status

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 iteratoriter(seq) starts fresh every time.

  • Slices are lazy tooseq[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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

countably-2026.5.17.3646.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

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

countably-2026.5.17.3646-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file countably-2026.5.17.3646.tar.gz.

File metadata

  • Download URL: countably-2026.5.17.3646.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

Hashes for countably-2026.5.17.3646.tar.gz
Algorithm Hash digest
SHA256 360a3247b26d981c6e4dcefc943eebd044bc277a157462ceb2ad0ade60928ae2
MD5 bbf738b1c79fdad7442fa6a4ed5fe4a5
BLAKE2b-256 6f6f0d1a03c30b1cf6bb77975e3903d20cd896a46b2d034dee0fbe0a2009c0b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for countably-2026.5.17.3646.tar.gz:

Publisher: release.yml on moshez/countably

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

File details

Details for the file countably-2026.5.17.3646-py3-none-any.whl.

File metadata

File hashes

Hashes for countably-2026.5.17.3646-py3-none-any.whl
Algorithm Hash digest
SHA256 6107cbb5c80be8ce43f93a54881294837c4e9899c60f9662c871da98270924ac
MD5 5e9bc8a8de862fbde0b6287780bf58d9
BLAKE2b-256 6aa6e8703408df145698c910b18963fd572f569fc2cc7ee9a733e832c80c6b27

See more details on using hashes here.

Provenance

The following attestation bundles were made for countably-2026.5.17.3646-py3-none-any.whl:

Publisher: release.yml on moshez/countably

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