Skip to main content

Transducers in Python

This is a port of the transducer concept from Clojure to Python, with an emphasis on providing as Pythonic as interpretation of transducers as possible, rather than reproducing Clojurisms more literally.

Installable Python package

This package is available on the Python Package Index (PyPI) as transducer.

Status

Build status:

Build Status Documentation Status

Note: Documentation is very much a work in progress.

What are transducers?

Transducers are functions which transform reducers - hence the name. A reducer, in this case, is any function which you could pass to the reduce() function in the Python Standard Library functools module. Such reducers accept an initial or intermediate result and combine a new value with that result to produce a new (or updated) result. Transducers provide us with a convenient means to compose simple reducers into more complex and capable reducers.

Furthermore, transducers facilitate the clean separation of concerns of how source values are input, how they are processed by reducers, and the how results output. This allows the same transducers to be (re)used with many sources and destinations of data, not just with iterable series.

Transducers were developed by Rich Hickey, the driving force behind the Clojure programming language, and this package aims to bring the benefits of transducers to Python 3, whilst transforming some of the Clojurisms into more Pythonic solutions.

An extended write-up of the development of Python transducers from scratch can be found in our series of articles Understanding Transducers Through Python. The code developed over the course of these articles is substantially the same as in this transducer package, although the package uses some further abstractions and tools which are largely irrelevant to understanding how transducers work.

This package, implements simple infrastructure for implementing transducers in Python, a selection of transducer implementations of common operations, and some ‘transducible processes’ which allow us to apply transducers to iterable series (both eagerly and lazily) and to use transducers to process ‘push’ events implemented as Python coroutines.

Release files for transducer 0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for transducer 0.9
File Size Uploaded
transducer-0.9.tar.gz 16.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for transducer 0.9
File Interpreter ABI Platform
transducer-0.9-py3-none-any.whl Python 3 none any Details

Total release size: 31.6 kB

Release files / transducer-0.9.tar.gz

Download URL transducer-0.9.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
628ad8d954b13e3687f613a91b94f6893bf05f6626bd559cb668c06317b1cef9
BLAKE2b-256 checksum
How to use checksums
d19e2cd095ec9fb5023b556350914f713e73ec684846f9e3350546440df0c1e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / transducer-0.9-py3-none-any.whl

Download URL transducer-0.9-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0486f4e2af4b65c9f5ac57d576a0e97955a4daa3d0fb5bbe9f9b787f3470f8f3
BLAKE2b-256 checksum
How to use checksums
47777af913f9e194f6a5c32d0ec95803580d36f8c1c67d1579b508c047de5cf8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.9 This release

2 release files

0.8

2 release files

0.7

2 release files

0.6

1 release file

0.5

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page