Skip to content

Release 0.20.0

Choose a tag to compare

@OutSquareCapital OutSquareCapital released this 21 May 00:51
· 1660 commits to master since this release

Pyochain v0.20.0

This release follow the pattern of 0.18 and 0.19 regarding changes for a leaner, cleaner API with better semantics.

Note that besides the first 4 points in the "breaking changes" section, the rest won't impact you unless you defined custom subclasses from the former traits module.

Changes

💥 Breaking changes

  • API change: pyochain::traits module is now pyochain::abc. If you were importing from pyochain.traits, update your imports to pyochain.abc instead.
  • Removed: PyoIterable::new. Call __init__(()) for the same behavior, e.g Seq(()), Iter(()), etc...
  • Removed: Unzipped and Peekable dataclasses. The Iter methods who constructed them now simply return tuples instead, simplifying the API and improving speed.
  • API change: Iter::sort (now in base class PyoIterator) has been split into Iter::sort and Iter::sort_by. If you were using Iter::sort(key=...), you should now use Iter::sort_by(key=...) instead. This should bring typing improvements as well as a clearer API.
  • API change: PyoIterable::__init__ is deleted. This means that subclasses are free to implement their own constructors, without typing constraints nor default behavior.

Methods migration to concrete parents

If you did not define custom classes from PyoSet or PyoIterator, skip to the Enhancements section.


The __init__ deletion from PyoIterable also means that all ABCs methods that relied on self::__class__ needed to move to their concrete pyochain parents, as they couldn't stay (nor should have ever been) purely abstract.

This concerns:

from PyoSet to Set ->

intersection, r_intersection, union, r_union, difference, r_difference, symmetric_difference, r_symmetric_difference


from PyoIterator to Iter ->

take_while, skip_while, compress, unique, unique_by, take, skip, step_by, slice, cycle, insert, intersperse, chain, accumulate


✨ Enhancements

  • Migrated: Iter::{collect_into, try_collect, sort, tail} have been moved to PyoIterator, meaning all user-defined subclasses can now call them (as well as sort_by)
  • Migrated: Vec::{drain, extract_if} have been moved to PyoMutableSequence, meaning all user-defined mutable sequence subclasses can now call them.

📖 Documentation

  • Improved various classes and methods documentation.
  • Reformatted all code examples with Ruff.
  • Added dev documentation regarding design choices on where to implement a method (abstract vs concrete class).

🔄 Refactors

  • Separated some classes in dedicated files to reduce the size of _iter.py and improve readability. Seq is now in _seq.py, Set and SetMut are now in _set.py notably.