Skip to main content

itersys

A lightweight Python library providing one-line iterator and algorithm helpers. Simplify your daily tasks with powerful utilities for chunking lists, flattening iterables, sliding windows, common algorithms, combinatorial operations, and nested dictionary utilities.

Installation

pip install itersys

Or install from source:

git clone https://github.com/ZeroDevsLtd/itersys.git
cd itersys
pip install -e .

Quick Start

import itersys

# Chunk a list
print(list(itersys.chunk([1, 2, 3, 4, 5], 2)))  # [[1, 2], [3, 4], [5]]

# Flatten nested structures
print(list(itersys.flatten([1, [2, 3], [4, [5]]])))  # [1, 2, 3, 4, 5]

# Sort with merge sort
print(itersys.merge_sort([5, 2, 9, 1]))  # [1, 2, 5, 9]

Features

Iteration Utilities (itersys.iteration)

chunk(iterable, size)

Split an iterable into chunks of the specified size.

from itersys.iteration import chunk

print(list(chunk([1, 2, 3, 4, 5], 2)))  # [[1, 2], [3, 4], [5]]
print(list(chunk("abcdef", 3)))  # [['a', 'b', 'c'], ['d', 'e', 'f']]

window(iterable, size)

Create a sliding window over an iterable.

from itersys.iteration import window

print(list(window([1, 2, 3, 4, 5], 3)))  # [(1, 2, 3), (2, 3, 4), (3, 4, 5)]

flatten(nested_iterable)

Flatten a nested iterable structure.

from itersys.iteration import flatten

print(list(flatten([1, [2, 3], [4, [5]]])))  # [1, 2, 3, 4, 5]
print(list(flatten([[1, 2], [3, 4]])))  # [1, 2, 3, 4]

unique_by(iterable, key=lambda x: x)

Return unique items from an iterable based on a key function.

from itersys.iteration import unique_by

print(list(unique_by([1, 2, 2, 3, 1])))  # [1, 2, 3]

# With custom key function
data = [{'a': 1}, {'a': 1}, {'a': 2}]
print(list(unique_by(data, lambda x: x['a'])))  # [{'a': 1}, {'a': 2}]

Algorithms (itersys.algorithms)

binary_search(arr, target)

Perform binary search on a sorted list.

from itersys.algorithms import binary_search

arr = [1, 2, 3, 4, 5]
print(binary_search(arr, 3))  # 2
print(binary_search(arr, 6))  # None

merge_sort(arr)

Sort a list using merge sort algorithm.

from itersys.algorithms import merge_sort

print(merge_sort([5, 2, 9, 1]))  # [1, 2, 5, 9]
print(merge_sort([3, 1, 4, 1, 5, 9, 2, 6]))  # [1, 1, 2, 3, 4, 5, 6, 9]

fibonacci(n)

Calculate the nth Fibonacci number.

from itersys.algorithms import fibonacci

print(fibonacci(5))  # 5
print(fibonacci(10))  # 55

gcd(a, b)

Calculate the greatest common divisor of two integers.

from itersys.algorithms import gcd

print(gcd(48, 18))  # 6
print(gcd(17, 13))  # 1

Combinatorics (itersys.combinatorics)

powerset(iterable)

Generate the powerset of an iterable (all possible subsets).

from itersys.combinatorics import powerset

print(list(powerset([1, 2, 3])))
# [(), (1,), (2,), (3,), (1, 2), (1, 3), (2, 3), (1, 2, 3)]

cartesian_product(*iterables)

Compute the Cartesian product of multiple iterables.

from itersys.combinatorics import cartesian_product

print(list(cartesian_product([1, 2], [3, 4])))
# [(1, 3), (1, 4), (2, 3), (2, 4)]

Utilities (itersys.utils)

deep_get(d, key_path, default=None)

Get a value from a nested dictionary using a dot-separated key path or list of keys.

from itersys.utils import deep_get

d = {"a": {"b": {"c": 42}}}
print(deep_get(d, "a.b.c"))  # 42
print(deep_get(d, ["a", "b", "c"]))  # 42
print(deep_get(d, "a.b.d", default=0))  # 0

deep_set(d, key_path, value)

Set a value in a nested dictionary using a dot-separated key path or list of keys.

from itersys.utils import deep_set

d = {}
deep_set(d, "a.b.c", 42)
print(d)  # {'a': {'b': {'c': 42}}}

deep_set(d, ["x", "y"], 10)
print(d)  # {'a': {'b': {'c': 42}}, 'x': {'y': 10}}

CLI Usage

The itersys package includes a command-line interface for quick operations:

Chunk Command

itersys chunk --input '[1,2,3,4,5]' --size 2
# Output: [[1,2],[3,4],[5]]

Flatten Command

itersys flatten --input '[1,[2,3],[4,[5]]]'
# Output: [1,2,3,4,5]

Import Examples

You can import functions in multiple ways:

# Import from main package
import itersys
print(list(itersys.chunk([1, 2, 3, 4], 2)))

# Import from specific modules
from itersys.iteration import chunk, flatten
from itersys.algorithms import merge_sort

# Import everything
from itersys import chunk, flatten, merge_sort, powerset

Testing

Run tests with pytest:

pytest tests/

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Metadata

Release files for itersys 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for itersys 0.1.0
File Size Uploaded Provenance Actions
itersys-0.1.0.tar.gz 10.6 kB With provenance Details for itersys-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for itersys 0.1.0
File Interpreter ABI Platform Actions
itersys-0.1.0-py3-none-any.whl Python 3 none any Details for itersys-0.1.0-py3-none-any.whl

Total release size: 19.8 kB

Release files / itersys-0.1.0.tar.gz

Download URL itersys-0.1.0.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
16b6f8eec3d7dadf82b0c31a94ea689eba0b32d768a208fd1db35f64f84bced1
BLAKE2b-256 checksum
How to use checksums
275efd2e548b1416f51cd89ba524fcc04791dae9843fce8ce74f70b8bae6d1bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 31, 2026.

Transparency log

Release files / itersys-0.1.0-py3-none-any.whl

Download URL itersys-0.1.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d51e6a00fc4c2584fb0512402c94e43cf3fd200d9e5f6e50661af5ddfcb29443
BLAKE2b-256 checksum
How to use checksums
5e96d85c18dab18bc2bf774394999407b0c0c503ad0e1325f89fb76a936da5bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 31, 2026.

Transparency log

Security for itersys 0.1.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for itersys-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 31, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page