transducers package


transducers.transducers module

class transducers.transducers.Missing[source]

Bases: object

Only for ‘is’ comparison to simplify arity testing. This is because None is a legal argument differing from ‘Not supplied.’

class transducers.transducers.Reduced(val)[source]

Bases: object

Only for ‘isinstance’ comparison to signal early termination of reduce.

transducers.transducers.append(r=<class 'transducers.transducers.Missing'>, x=<class 'transducers.transducers.Missing'>)[source]

Appender used by into. Will work with lists, deques, or anything with an appender.[source]

Cat transducers (will cat items from nested lists, e.g.).


Compose functions using reduce on splat.

compose(f, g) reads ‘f composed with g’, or f(g(x))

Note: order of inner function application with transducers is inverted from the composition of the transducers.


Removes duplicatees that occur in order. Accepts first inputs through and drops subsequent duplicates.


Drops n items from beginning of input sequence.


Drops values so long as a condition is true.

transducers.transducers.eduction(xf, coll)[source]

Return a generator with transform applied. Not implemented.


Transducer version of filter.

transducers.transducers.into(target, xducer, coll)[source]

Transduces items from coll into target. :TODO: Write improved dispatch for collections?


Keep pred items for which pred does not return None.


Keep values where f does not return None. f for keep indexed is a function that takes both index and value as inputs.[source]

Transducer version of map, returns f(item) with each reduction step.


Mapcat transducer - maps to a collection then cats item into one less level of nesting.


Splits inputs into lists of size n.


Split inputs into lists by starting a new list each time the predicate passed in evaluates to a different condition (true/false) than what holds for the present list.

transducers.transducers.random() → x in the interval [0, 1).

Has prob probability of returning each input it receives.

transducers.transducers.reduce(function, iterable, initializer=<class 'transducers.transducers.Missing'>)[source]

For loop impl of reduce in Python that honors sentinal wrapper Reduced and uses it to signal early termination.


Remove anything that satisfies pred.


Replaces keys in smap with corresponding values.


Takes n values from a collection.


Takes every nth item from input values.


Takes while a condition is true. Note that take_while will take the first input that tests false, so be mindful of mutable input sources.

transducers.transducers.transduce(xform, f, start, coll=<class 'transducers.transducers.Missing'>)[source]

Return the results of calling transduce on the reducing function, can compose transducers using compose defined above.


Module contents

transducers.random() → x in the interval [0, 1).

Table Of Contents

Previous topic

Welcome to transducers documentation!

This Page