Skip to main content

ReactiveX (Rx) for Python

Project description

Build Status Coverage Status PyPY Package Version Documentation Status

A library for composing asynchronous and event-based programs using observable collections and query operator functions in Python

ReactiveX for Python v4

For v3.X please go to the v3 branch.

ReactiveX for Python v4.x runs on Python 3.7 or above. To install:

pip3 install reactivex

About ReactiveX

ReactiveX for Python (RxPY) is a set of libraries for composing asynchronous and event-based programs using observable sequences and pipable query operators in Python. Using Rx, developers represent asynchronous data streams with Observables, query asynchronous data streams using operators, and parameterize concurrency in data/event streams using Schedulers.

import reactivex as rx
from reactivex import operators as ops

source = rx.of("Alpha", "Beta", "Gamma", "Delta", "Epsilon")

composed = source.pipe(
    ops.map(lambda s: len(s)),
    ops.filter(lambda i: i >= 5)
)
composed.subscribe(lambda value: print("Received {0}".format(value)))

Learning ReactiveX

Read the documentation to learn the principles of ReactiveX and get the complete reference of the available operators.

If you need to migrate code from RxPY v1.x, read the migration section.

There is also a list of third party documentation available here.

Community

Join the conversation on Slack!

The gracious folks at PySlackers have given us a home in the #rxpy Slack channel. Please join us there for questions, conversations, and all things related to RxPY.

To join, navigate the page above to receive an email invite. After signing up, join us in the #rxpy channel.

Please follow the community guidelines and terms of service.

Differences from .NET and RxJS

ReactiveX for Python is a fairly complete implementation of Rx with more than 120 operators, and over 1300 passing unit-tests. RxPY is mostly a direct port of RxJS, but also borrows a bit from Rx.NET and RxJava in terms of threading and blocking operators.

ReactiveX for Python follows PEP 8, so all function and method names are lowercase with words separated by underscores as necessary to improve readability.

Thus .NET code such as:

var group = source.GroupBy(i => i % 3);

need to be written with an _ in Python:

group = source.pipe(ops.group_by(lambda i: i % 3))

With ReactiveX for Python you should use named keyword arguments instead of positional arguments when an operator has multiple optional arguments. RxPY will not try to detect which arguments you are giving to the operator (or not).

Development

This project is managed using Poetry. Code is formatted using Black, isort. Code is statically type checked using pyright and mypy.

If you want to take advantage of the default VSCode integration, then first configure Poetry to make its virtual environment in the repository:

poetry config virtualenvs.in-project true

After cloning the repository, activate the tooling:

poetry install
poetry run pre-commit install

Run unit tests:

poetry run pytest

Run code checks (manually):

poetry run pre-commit run --all-files

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

ReactiveX-4.0.0b1.tar.gz (118.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ReactiveX-4.0.0b1-py3-none-any.whl (217.4 kB view details)

Uploaded Python 3

File details

Details for the file ReactiveX-4.0.0b1.tar.gz.

File metadata

  • Download URL: ReactiveX-4.0.0b1.tar.gz
  • Upload date:
  • Size: 118.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.10 Linux/5.11.0-1028-azure

File hashes

Hashes for ReactiveX-4.0.0b1.tar.gz
Algorithm Hash digest
SHA256 b6b419affd0dc44e3954f91b03519c6083fa44c481812d73730a0d25a9fd6112
MD5 811ef49b65dcb540e41c307599d1917d
BLAKE2b-256 42ae311d2aff2a1ebba600468478d997e2c91e86293d4aa5cefdcb38c78f7b78

See more details on using hashes here.

File details

Details for the file ReactiveX-4.0.0b1-py3-none-any.whl.

File metadata

  • Download URL: ReactiveX-4.0.0b1-py3-none-any.whl
  • Upload date:
  • Size: 217.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.10 Linux/5.11.0-1028-azure

File hashes

Hashes for ReactiveX-4.0.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 1d9b22e1a4deab2bbf8d54ea202c039585f36d44c6b7656f62f244e2b5db6d40
MD5 2b386b1b30f81bbe17a80dc57915387c
BLAKE2b-256 0dc9326a165dfc4c5936bfd61a68b496eb7a122cfaaca86741d22bfffa1fa684

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page