Skip to main content

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_longest take exactly two inputs of the same element type (no variadic forms).
  • permutations/combinations/combinations_with_replacement/batched yield list[T] rows instead of tuples (row arity is not statically known).
  • repeat(x, times) uses times=-1 as the "not given" sentinel (infinite); CPython treats negative counts as empty.
  • islice uses stop=-2 as the "one-argument form" sentinel and stop=-1 for CPython's None (unbounded).
  • accumulate supports plain + accumulation only (no func/initial).
  • zip_longest requires fillvalue; count is int-only.
  • starmap, groupby and tee are not provided (*args application, 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)

Source distribution for serp-itertools 0.2.0
File Size Uploaded
serp_itertools-0.2.0.tar.gz 6.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for serp-itertools 0.2.0
File Interpreter ABI Platform
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 log

Release 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

Release history Release notifications | RSS feed

This release

0.2.0 This release

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