Inspired by Java 8 streams, simple list processing
Project description
Inspired by Java 8’s streams, this Python module provides a fluent syntax for manipulating and querying Python lists. It’s called lazy-streams because it lazy evaluates the requests to increase performance and decrease resource requirements. Because of the lazy evaluation, lazy-streams can work on really large data sets with relatively small delays.
Here’s a quick example:
>>> from lazy_streams import stream >>> s = stream(range(5000000)) \ ... .filter(lambda x: str(x)[0] == '3') \ ... .map(lambda x: -x) \ ... .map(lambda x: "Item: %s" % x) \ ... .take(75) \ ... .reverse() >>> print s.first_or_else() Item: -363 >>> print s.take(5).to_list() ['Item: -363', 'Item: -362', 'Item: -361', 'Item: -360', 'Item: -359'] >>> print s.take(3).to_string() Item: -363, Item: -362, Item: -361
Lazy-streams is intended to be a small (single-file), light-weight, simple implementation that relies on a mimimal set of dependencies.
As you can see from the above example, you can stack multiple manipulations on top of each other. The module will optimize the execution to only perform the operations on the elements of the list that are involved in the eventual output.
Also, the original list will remain unchanged as the output of each operation simply returns a delta from the original value.
Documentation and more examples are available docs.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for lazy_streams-0.4-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dbfd30952ac82cc5afc7b862a4f7f19b7c084f41bc7e0c4df5fd36c192d5a252 |
|
MD5 | a2c949d57647ef02a843d0a861c2d992 |
|
BLAKE2b-256 | abb17d1d9aea32eec9e4e7e2a5a8834a9dd55b879c6250fa69dea11212549319 |