Version 0.13.1
·
2148 commits
to master
since this release
"Maybe a slice?" edition
New:
view
: writable, sliceable view into a sequence. Use likeview(lst)[::2]
. Can be nested (i.e. sliced again). Any access (read or write) goes through to the original underlying sequence. Can assign a scalar to a slice à la NumPy. Stores slices, not indices; works also if the length of the underlying sequence suddenly changes.islice
: slice syntax support foritertools.islice
, use likeislice(myiterable)[100:10:2]
orislice(myiterable)[42]
. (It's essentially a curried function, where the second step uses the subscript syntax instead of the function call syntax.)prod
: likesum
, but computes the product. A missing battery.iindex
: likelist.index
, but for iterables. A missing battery. (Makes sense mostly for memoized input.)inn(x, iterable)
: contains-check (x in iterable
) for monotonic infinite iterables, with automatic termination.getattrrec
,setattrrec
(recursive): access underlying data in an onion of wrappers.primes
andfibonacci
generators, mainly intended for testing and usage examples.SequenceView
andMutableSequenceView
abstract base classes;view
is aMutableSequenceView
.
Breaking changes:
- The
fup[]
utility macro to functionally update a sequence is gone and has been replaced by thefup
utility function, with slightly changed syntax to accommodate. New syntax is likefup(lst)[3:17:2] << values
. (This is a two-step curry utilizing the subscript and lshift operators.) ShadowedSequence
, and hence alsofupdate
, now raise the semantically more appropriateIndexError
(instead of the previousValueError
) if the replacement sequence is too short.namelambda
now returns a modified copy; the original function object is no longer mutated.
Non-breaking improvements:
ShadowedSequence
now supports slicing (read-only), equality comparison,str
andrepr
. Out-of-range access to a single item emits a meaningful error, like inlist
.env
anddyn
now provide thecollections.abc.Mapping
API.cons
and friends:BinaryTreeIterator
andJackOfAllTradesIterator
now support arbitarily deep cons structures.