While Python was originally intended as an imperative language
[Guido], it contains all elements necessary to support a rich set of features
from the functional paradigm. In particular its core data structures, lazy
iterators, and functions as first class objects can be combined to implement a
common standard library of functions shared among many functional languages.
This was first recognized and supported through the standard libraries
itertools and functools which contain functions like
partial to complement the standard
reduce already found in the core language. While these libraries contain
substantial functionality they do not achieve the same level of adoption found
in similar projects in other languages. This may be because they are
incomplete and lack a number of commonly related functions like
groupby which often complement these core operations.
A completion of this set of functions was first attempted in the projects
itertoolz and functoolz (note the z). These libraries contained
several functions that were absent in the standard itertools/functools
functoolz libraries were eventually merged
into the monolithic
toolz project described here.
Most contemporary functional languages (Haskell, Scala, Clojure, …) contain
some variation of the functions found in
generally adheres closely to the API found in the Clojure standard library (see
cheatsheet) and where disagreements occur that API usually dominates. The
toolz API is also strongly affected by the principles of the Python
language itself, and often makes deviations in order to be more approachable to
The development of a functional standard library within a popular imperative
language is not unique. Similar projects have arisen in other
imperative-by-design languages that contain the necessary elements to support a
notable popularity in the web community.
LINQ in C# follows a similar
philosophy but mimics declarative database languages rather than functional
ones. Enumerable is is the closest project in Ruby. Other excellent projects
also exist within the Python ecosystem, most notably Fn.py and Funcy.