Version 0.13.1
·
2173 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.primesandfibonaccigenerators, mainly intended for testing and usage examples.SequenceViewandMutableSequenceViewabstract base classes;viewis aMutableSequenceView.
Breaking changes:
- The
fup[]utility macro to functionally update a sequence is gone and has been replaced by thefuputility 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.namelambdanow returns a modified copy; the original function object is no longer mutated.
Non-breaking improvements:
ShadowedSequencenow supports slicing (read-only), equality comparison,strandrepr. Out-of-range access to a single item emits a meaningful error, like inlist.envanddynnow provide thecollections.abc.MappingAPI.consand friends:BinaryTreeIteratorandJackOfAllTradesIteratornow support arbitarily deep cons structures.