Release 0.3.0: nth/interleave fixes, add chunk_by#15
Merged
Conversation
- nth is now 0-based, consistent with Rust's Iterator::nth and Python indexing (BREAKING: drop the +1 in callers; nth(0) now valid) - interleave yields the remainder of the longer iterable once the shorter is exhausted, matching Rust (BREAKING: previously truncated) - add chunk_by: lazy, order-preserving grouping of consecutive runs (itertools.groupby / Rust chunk_by semantics; works on infinite iterators) - document groupby/value_counts as eager (sorts input); note equivalence to pandas default groupby; fix nth docstring - bump version to 0.3.0; refresh apidoc, README and release notes Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes from a codebase review, plus a small new method. Bumps the version to 0.3.0.
Breaking changes
nthis now 0-based — consistent with Rust'sIterator::nthand Python's indexing conventions.nth(0)returns the first item (previously raisedValueError;nth(1)returned the first item). Drop the+ 1in callers.interleavenow yields the tail of the longer iterable once the shorter is exhausted, matching Rust'sinterleave(previously it stopped at the shorter input and silently dropped the remainder).New features
chunk_by— lazily groups consecutive elements sharing a key (itertools.groupby/ Rustchunk_bysemantics). Unlikegroupbyit does not sort, so it preserves order and works on infinite iterators.Documentation
groupby(andvalue_counts) is eager: it sorts the whole input up front, so it reorders output, requires mutually-orderable keys, and must not be used on infinite sources. Noted it is semantically equivalent to pandas' default (sort=True)groupby.nthdocstring (it raisesStopIteration, not returnsNone).doc/apidoc.md.Also includes the
typre-commit hook addition.Test plan
pytest— 142 passed, 100% coverage (gate enforced)ruff checkandty checkclean🤖 Generated with Claude Code