Skip to content

Release 0.3.0: nth/interleave fixes, add chunk_by#15

Merged
virgesmith merged 1 commit into
mainfrom
fix/review-fixes
Jun 14, 2026
Merged

Release 0.3.0: nth/interleave fixes, add chunk_by#15
virgesmith merged 1 commit into
mainfrom
fix/review-fixes

Conversation

@virgesmith

Copy link
Copy Markdown
Owner

Summary

Fixes from a codebase review, plus a small new method. Bumps the version to 0.3.0.

Breaking changes

  • nth is now 0-based — consistent with Rust's Iterator::nth and Python's indexing conventions. nth(0) returns the first item (previously raised ValueError; nth(1) returned the first item). Drop the + 1 in callers.
  • interleave now yields the tail of the longer iterable once the shorter is exhausted, matching Rust's interleave (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 / Rust chunk_by semantics). Unlike groupby it does not sort, so it preserves order and works on infinite iterators.

Documentation

  • Clarified that groupby (and value_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.
  • Fixed the nth docstring (it raises StopIteration, not returns None).
  • Corrected the lazy/eager categorisation in the README; regenerated doc/apidoc.md.

Also includes the ty pre-commit hook addition.

Test plan

  • pytest — 142 passed, 100% coverage (gate enforced)
  • ruff check and ty check clean
  • Pre-commit hooks pass

🤖 Generated with Claude Code

- 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>
@virgesmith virgesmith merged commit 4a405c1 into main Jun 14, 2026
9 checks passed
@virgesmith virgesmith deleted the fix/review-fixes branch June 14, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant