The `nr-stream` package provides utilities for writing functional-style code in Python, offering `Stream`, `Optional`, and `Refreshable` classes. The `Stream` class wraps iterables to enable chained modifiers, simplifying common operations. `Optional` represents a value that might be `None`, allowing for safe chaining, while `Refreshable` acts as a container for values that can be updated, propagating changes to listeners. The current version is 1.1.5, released on February 14, 2023, with an active but irregular release cadence.
pip install nr-streamVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the core `Stream` class for chained iterable operations, as well as basic usage of the `Optional` and `Refreshable` utilities. The `Stream` example shows how to chunk and transform data, while `Optional` handles potentially absent values, and `Refreshable` illustrates reactive updates.
If you need to perform multiple independent operations on the same data, create a new `Stream` instance for each operation, or materialize the `Stream` (e.g., into a list) before branching operations.
Be aware that any `map` or `filter` operations on a `Refreshable` create new `Refreshable` instances that will re-evaluate their transformation eagerly when the source `Refreshable` is updated. Design your computation graphs accordingly, avoiding heavy computations in frequently updated chains unless intended.
Create a new `Stream` instance from the original data source (e.g., `Stream(my_list)`) for each sequence of operations that needs to start from the beginning of the data.
Understand that `Refreshable` is designed for 'reactive' updates where all dependants are immediately notified and re-evaluated. If you require lazy evaluation or deferment of computation until explicitly requested, `Refreshable` might not be the appropriate tool, or you need to manage when updates are triggered more carefully.
No dependency data recorded yet.