Good with Computers

The Sixty North Blog

Understanding Transducers through Python

A series of 8 articles:

  1. Deriving Transducers from First Principles
  2. Improving Transducer Composition
  3. Enriching the Transducer Protocol
  4. Stateful Transducers
  5. Terminating Transducers
  6. Item Injecting Transducers
  7. Lazy Transducer Evaluation
  8. Event Processing with Transducers


In this series we take an in-depth look at transducers. Transducers – a portmanteau of ‘transform reducers’ – are a new functional programming concept introduced into the Clojure programming language. Although transducers are actually pretty straightforward in retrospect, wrapping your brain around them, especially if you’re not already a competent Clojureist, can be challenging.

In this series, we introduce transducers by implementing them from scratch in everybody’s favourite executable pseudocode, Python. We’ll start with the familiar staples of functional programming, map(), filter() and reduce(), and derive transducers from first principles. We’ll work towards a set of general tools which works with eager collections, lazy ‘pull’ sequences, and ‘push’ event streams. Along the way we’ll cover stateful transducers and transducer composition, demonstrating that transducers are both more general, and more fundamental, than the functional programming tools baked into Python and many other languages.

By the end of this series, not only should transducers make sense to you, but you’ll have a recipe for implementing transducers in your own favourite programming language.

Stay in Touch

Our business hours are 08:00 to 16:00 CET/CEST.