Quick Start

Get started in just a few seconds!

Installation

To start using PyStreamAPI just install the core module with this command:

pip install streams.py

If you want to install pystreamapi together with the optional extensions, use this command:

pip install 'streams.py[all]'

This will install pystreamapi together with all optional loaders. You can also install those extensions individually, as described on following page:

Data Loaders

Afterward, you can import it with:

from pystreamapi import Stream

🎉 PyStreamAPI is now ready to process your data

Build a new Stream

PyStreamAPI offers two types of Streams, both of which are available in either sequential or parallel versions:

  • (Normal) Stream: Offers operations that do not depend on the types. The same functionality as Streams in other programming languages.

  • NumericStream: This stream extends the capabilities of the default stream by introducing numerical operations. It is designed specifically for use with numerical data sources and can only be applied to such data.

There are a few factory methods that create new Streams:

Stream.of()

Stream.of([1, 2, 3]) # Can return a sequential or a parallel stream

Using the of() method will let the implementation decide which Stream to use. If the source is numerical, a NumericStream is created.

Currently, it always returns a SequentialStream or a SequentialNumericStream

Stream.parallel_of()

Stream.parallel_of([1, 2, 3]) # Returns a parallel stream (Either normal or numeric)

Stream.sequential.of()

Stream.sequential_of([1, 2, 3]) # Returns a sequential stream (Either normal or numeric)

Stream.of_noneable()

# Can return a sequential or a parallel stream (Either normal or numeric)
Stream.of_noneable([1, 2, 3])

# Returns a sequential or a parallel, empty stream (Either normal or numeric)
Stream.of_noneable(None) 

If the source is None, you get an empty Stream

Stream.iterate()

Stream.iterate(0, lambda n: n + 2)

Creates a Stream of an infinite Iterator created by iterative application of a function f to an initial element seed, producing a Stream consisting of seed, f(seed), f(f(seed)), etc.

Note Do not forget to limit the stream with .limit()

Stream.concat()

Stream.concat(Stream.of([1, 2]), Stream.of([3, 4])) 
# Like Stream.of([1, 2, 3, 4])

Creates a new Stream from multiple Streams. Order doesn't change.

Last updated