Skip to content

Version 0.13.1

Compare
Choose a tag to compare
@Technologicat Technologicat released this 01 Mar 08:49
· 2084 commits to master since this release

"Maybe a slice?" edition

New:

  • view: writable, sliceable view into a sequence. Use like view(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 for itertools.islice, use like islice(myiterable)[100:10:2] or islice(myiterable)[42]. (It's essentially a curried function, where the second step uses the subscript syntax instead of the function call syntax.)
  • prod: like sum, but computes the product. A missing battery.
  • iindex: like list.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 and fibonacci generators, mainly intended for testing and usage examples.
  • SequenceView and MutableSequenceView abstract base classes; view is a MutableSequenceView.

Breaking changes:

  • The fup[] utility macro to functionally update a sequence is gone and has been replaced by the fup utility function, with slightly changed syntax to accommodate. New syntax is like fup(lst)[3:17:2] << values. (This is a two-step curry utilizing the subscript and lshift operators.)
  • ShadowedSequence, and hence also fupdate, now raise the semantically more appropriate IndexError (instead of the previous ValueError) 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 and repr. Out-of-range access to a single item emits a meaningful error, like in list.
  • env and dyn now provide the collections.abc.Mapping API.
  • cons and friends: BinaryTreeIterator and JackOfAllTradesIterator now support arbitarily deep cons structures.