Rich iterator for Python 3
Project description
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
)
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 iter2-2.0.1746745800.tar.gz.
File metadata
- Download URL: iter2-2.0.1746745800.tar.gz
- Upload date:
- Size: 27.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.2 Linux/6.8.0-57-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67b39db21177fdc85f654f395d80234c95ad59171c0733f164a0a2d8101c9a73
|
|
| MD5 |
3faa87169d88525465a480fc5d36631f
|
|
| BLAKE2b-256 |
b0c35584ed6e31f495a4325a99b5e16d3d19a7e9960c822c46f5be09e8e62589
|
File details
Details for the file iter2-2.0.1746745800-py3-none-any.whl.
File metadata
- Download URL: iter2-2.0.1746745800-py3-none-any.whl
- Upload date:
- Size: 59.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.2 Linux/6.8.0-57-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bcc46897411b2b3aa5705faf976d19d3d7b46934c517ad29bd17907d4b761f3
|
|
| MD5 |
5a2d3f5679fd80e8b3246b2437cad432
|
|
| BLAKE2b-256 |
922b14ff18d744877194e6ff49dc3cb84d235af49e1382f82657d2048016d318
|