mrocklin/toolz — pull request #15 by jruere (2014-12-16 00:03:06+00:00)
Title: Compose does more work on __init__ to do less on call.

The change in this pull makes compose more efficient.

I noticed compose in the profile of an app which prompted me to look at the implementation.

The original timing:

$ python2 -m timeit -s 'from toolz.functoolz import compose, identity; f = compose(*([identity]*10))' 'f(10)'
100000 loops, best of 3: 3.01 usec per loop

With the change:

$ python2 -m timeit -s 'from toolz.functoolz import compose, identity; f = compose(*([identity]*10))' 'f(10)'
1000000 loops, best of 3: 1.59 usec per loop