serp-itertools
Drop-in facade for CPython's itertools, written in the Serpentine subset.
Iterators are real lazy objects (classes implementing __iter__/__next__),
so count() and cycle() are genuinely infinite, next(it) works, and
for x in it: drains them exactly like CPython. Swap
import serp_itertools for import itertools on the supported surface.
Verified against the real itertools with a randomized differential
(8801/8801 checks) and byte-identical across CPython + both native backends.
Supported API
count(start=0, step=1), cycle(xs), repeat(obj[, times]),
chain(a, b), islice(xs, stop | start, stop[, step]),
compress(data, selectors), accumulate(xs), pairwise(xs),
product(a, b), zip_longest(a, b, fillvalue),
takewhile(pred, xs), dropwhile(pred, xs), filterfalse(pred, xs),
batched(xs, n), permutations(xs[, r]), combinations(xs, r),
combinations_with_replacement(xs, r).
Divergences from CPython
- Inputs are
list[T](the subset's iterable) with Copy element types; iterators snapshot their input at construction time. chain/product/zip_longesttake exactly two inputs of the same element type (no variadic forms).permutations/combinations/combinations_with_replacement/batchedyieldlist[T]rows instead of tuples (row arity is not statically known).repeat(x, times)usestimes=-1as the "not given" sentinel (infinite); CPython treats negative counts as empty.isliceusesstop=-2as the "one-argument form" sentinel andstop=-1for CPython'sNone(unbounded).accumulatesupports plain+accumulation only (nofunc/initial).zip_longestrequiresfillvalue;countis int-only.starmap,groupbyandteeare not provided (*argsapplication, nested group iterators, and tuple-of-iterators returns are out of subset).
Install
serp add serp-itertools
pip install serp-itertools
Metadata
Release files for serp-itertools 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| serp_itertools-0.2.0.tar.gz | 6.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| serp_itertools-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.0 kB
Release files / serp_itertools-0.2.0.tar.gz
| Download URL | serp_itertools-0.2.0.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe50fcbcde1c11bb8efe958fa2e0f120147ac7f006a372a2ab7f5ffa6df60919
|
|
BLAKE2b-256 checksum How to use checksums |
28148053fa31620169948abba89dbeb7507e3dcfeec77d7c8c2d892b855e9b2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 29, 2026.
Transparency logRelease files / serp_itertools-0.2.0-py3-none-any.whl
| Download URL | serp_itertools-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9868b088f3c80a8468f7c5d5158911546e40b66a9b5cd4598ebb2f7ca5415cee
|
|
BLAKE2b-256 checksum How to use checksums |
25376739a97d036c145fccc767d49f8981b9f0f9ec2440c1dabe7d5084fdae79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 29, 2026.
Transparency log