EuroPython 2015

Functional Programming with Transducers in Python

Transducers – a portmanteau of ‘transform reducers’ – are a new functional programming concept, which were first introduced into the Clojure programming language. Although transducers are actually pretty straightforward in retrospect, wrapping your brain around them can be challenging.

Transducers allow us to fuse multiple data processing operations together so they can be applied in a single pass over a data series – similar to how Python generator functions allow us to process iterable series. However, unlike generator functions they are completely decoupled from the data series abstraction and can be used on eager sequences, lazy iterables, coroutine-based push events and events such as those modelled by Reactive Extensions for Python (RxPy).

In this workshop, we introduce transducers by implementing them from scratch in Python 3. 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 coroutine ‘push’ event streams and RxPy. 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.

There are no prerequisites for this workshop as we stick to core Python 3 language features although an enthusiasm for a functional programming style will be sure to help attendees get the most out of this session.

in on Thursday 23 July at 14:30 See schedule

Comments

  1. Gravatar
    The training seems interesting.

    I'd like to know a detailed track, and understand how to manage it in 3 hours.

    References to slides, code snippets & co, ipython notebooks are welcome!

    Peace,
    R.
    — Roberto Polli,
  2. Gravatar
    You can read a series of at least eight articles here which cover the material in the workshop. I've done this several times as a 90 minute solo live-coding exercise so I expect three hours to be sufficient for a workshop.

    http://sixty-north.com/blog/series/understanding-transducers-through-python
    — Robert Smallshire,

New comment