Repository navigation
Release 0.6.4
π pyochain 0.6.4 β Release Notes
Date: 2026-01-09 π
π Highlights
- Methods Reorganization: PyoIterable β Iter
- Deprecated Methods Removal from Dict and Option
- Option.if_true() API Improvement
- Various documentation improvements
π API Changes
Migrated: from PyoIterable to Iter
Several methods have been moved from the PyoIterable base trait to Iter only, as they don't make sense on unordered collections like Dict and Set:
all_equal()all_unique()argmax()argmin()is_sorted()
Why? Dict, Set, and SetMut are unordered/non-comparable collections. Having sorting/uniqueness checks on them is semantically incorrect.
Migration:
# Before (on Seq, Vec)
seq.is_sorted()
seq.all_unique()
seq.argmax()
# After
seq.iter().is_sorted()
seq.iter().all_unique()
seq.iter().argmax()Removed: Deprecated Dict Methods
The following deprecated methods have been permanently removed from Dict:
- β
map_items() - β
map_keys() - β
map_values() - β
filter_items() - β
filter_keys() - β
filter_values().
Migration: Use .iter().map_star(...).collect(pc.Dict) or .iter().filter_star(...).collect(pc.Dict) instead:
# Before
d.map_keys(str.lower)
d.filter_values(lambda v: v > 0)
# After
d.iter().map_star(lambda k, v: (str.lower(k), v)).collect(pc.Dict)
d.iter().filter_star(lambda k, v: v > 0).collect(pc.Dict)Note:
You can still chain dictionary transformations with .into() calls wrapping cytoolz functions, e.g.:
import cytoolz as cz
import pyochain as pc
res = pc.Dict.from_kwargs(a=1, b=2).into(
lambda d: pc.Dict(cz.dicttoolz.keyfilter(lambda k: k == "a", d))
)
# Dict('a': 1)Why?
- Encourages explicit chaining via
Iter. - Discourage long chain of transformation on dictionaries, which is inefficient since each step create a new intermediate
dict-> hashing, no-lazy evaluation, no unpacking for*_item()methods, etc... - When the new
frozendicttype from PEP 814 is introduced, it will might make sense to bring those methods back, since they internally always returned newdictinstances under the hood.
Removed: Option.from_() Deprecated Method
The deprecated Option.from_() method has been removed. Use Option() constructor instead:
# Before
pc.Option.from_(value)
# After
pc.Option(value) # Same behaviorEnhanced: Option.if_true() Now Applies Predicate to Value
The Option.if_true() method has been improved to apply the predicate directly to the provided value, making it more ergonomic:
Before:
# Predicate received NO arguments - had to capture external state
pc.Option.if_true(42, predicate=lambda: external_check)After:
# Predicate now receives the value itself
pc.Option.if_true(42, predicate=lambda x: x == 42)
pc.Option.if_true(42, predicate=lambda x: x > 0)
# Can call methods directly on the value
from pathlib import Path
pc.Option.if_true(Path("file.txt"), predicate=Path.exists)
pc.Option.if_true(Path("file.txt"), predicate=lambda p: p.exists())Questions? Report issues on our GitHub Issues page.