Skip to main content

iter2

This library provides implementation of rich-iterator concept, inspired by Rust's std::iter::Iterator, Java's Stream and more-itertools library.

The original purpose of this tool was to be used within a REPL (primarily IPython) environment for processing streaming data.

The goal of v2.x is to build upon the 7 years of experience gained from the production use of v1.x, to factor out redundant functionality, and to create a well-typed public API.

Usage

iter2 - the main API of this library, behaves like builtin iter but creates an instance of iter2.interfaces.Iterator2.

iter2.interfaces - module with library specific interfaces like Iterator2 and Iterable2.

iter2.algo - module with all algorithms and their curried versions.

iter2.op - module with useful operators like nth_item, pipe and mapping_items.

iter2.box and iter2.option - modules with types of "boxed values" Box2 and Option2.

import typing as tp

from iter2 import iter2


DATA: tp.Sequence[tp.Tuple[str, int | float]] = ...  # type: ignore

result: float | complex = (
    iter2(DATA)
    .filter_unpacked(lambda title, _: (
        title.startswith('Static typing')
    ))  # Iterator2[tp.Tuple[str, int | float]]
    .map_unpacked(lambda _, value: (
        -value,
    ))  # Iterator2[int | float]
    .filter_by_type(float)  # Iterator2[float]
    .apply_raw(
        iter2.algo.find_max_value
    )  # Option2[float]
    .value_or_else(lambda: 31337j)  # float | complex
)

Release files for iter2 2.0.1746745800

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

Source distribution (sdist)

Source distribution for iter2 2.0.1746745800
File Size Uploaded
iter2-2.0.1746745800.tar.gz 27.0 kB Details

Built distribution (wheel)

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

Total release size: 86.6 kB

Release files / iter2-2.0.1746745800.tar.gz

Download URL iter2-2.0.1746745800.tar.gz
Size 27.0 kB
Tags Source
SHA-256 checksum
How to use checksums
67b39db21177fdc85f654f395d80234c95ad59171c0733f164a0a2d8101c9a73
BLAKE2b-256 checksum
How to use checksums
b0c35584ed6e31f495a4325a99b5e16d3d19a7e9960c822c46f5be09e8e62589
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.2 Linux/6.8.0-57-generic

Release files / iter2-2.0.1746745800-py3-none-any.whl

Download URL iter2-2.0.1746745800-py3-none-any.whl
Size 59.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9bcc46897411b2b3aa5705faf976d19d3d7b46934c517ad29bd17907d4b761f3
BLAKE2b-256 checksum
How to use checksums
922b14ff18d744877194e6ff49dc3cb84d235af49e1382f82657d2048016d318
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.2 Linux/6.8.0-57-generic

Release history Release notifications | RSS feed

This release

2.0.1746745800 This release

2 release files

1.1

2 release files

1.0

2 release files

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