sandbox
Functions –
- parallel.fold(binop, seq[, default, map, …] – Reduce without guarantee of ordered reduction.
import
toolz
def
sum
(a, b):
return
a
+
b
print
(toolz.sandbox.parallel.fold(
sum
, [
1
,
2
,
3
,
4
]))
Output –
10
- core.unzip(seq) – Inverse of zip.
import
toolz
l1, l2
=
toolz.sandbox.core.unzip([(
0
,
1
),
(
1
,
2
),
(
2
,
3
)])
print
(
list
(l1),
list
(l2))
Output –
[0, 1, 2] [1, 2, 3]
Toolz module in Python
Toolz package provides a set of utility functions for iterators, functions, and dictionaries. These functions extend the standard libraries itertools and functools and borrow heavily from the standard libraries of contemporary functional languages. This package consists of following modules –
- dicttoolz
- functoolz
- itertoolz
- recipes
- sandbox