Metadata-Version: 2.4
Name: countably
Version: 2026.5.17.3646
Summary: Infinite number sequences
Author-email: Moshe Zadka <moshez@zadka.club>
License: Permission is hereby granted, free of charge, to any person obtaining a
        copy of this software and associated documentation files (the "Software"),
        to deal in the Software without restriction, including without limitation the
        rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is furnished
        to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
        INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
        PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
        HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
        CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
        OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
        
Project-URL: Homepage, https://github.com/moshez/countably
Description-Content-Type: text/x-rst
Provides-Extra: tests
Requires-Dist: virtue; extra == "tests"
Requires-Dist: pyhamcrest; extra == "tests"
Requires-Dist: coverage; extra == "tests"
Provides-Extra: mypy
Requires-Dist: mypy; extra == "mypy"
Provides-Extra: lint
Requires-Dist: flake8; extra == "lint"
Requires-Dist: black; extra == "lint"
Requires-Dist: stolid; extra == "lint"
Provides-Extra: docs
Requires-Dist: sphinx; extra == "docs"

countably
=========

.. image:: https://img.shields.io/pypi/v/countably.svg
   :target: https://pypi.org/project/countably/
   :alt: PyPI version

.. image:: https://img.shields.io/pypi/pyversions/countably.svg
   :target: https://pypi.org/project/countably/
   :alt: Supported Python versions

.. image:: https://readthedocs.org/projects/countably/badge/?version=latest
   :target: https://countably.readthedocs.io/en/latest/
   :alt: 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:

.. code-block:: python

    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
-------

.. code-block:: bash

    pip install countably
