Toolz vs Funcy vs More-Itertools in 2026: Which Python Functional Library Earns Its Import?

You know the shape of the problem: a list of order dicts needs to be filtered, grouped, summed, and reshaped, and forty minutes later you are four indentation levels deep inside nested for loops with a result = [] accumulator at the top. Python’s itertools helps, but it gives you primitives, not vocabulary. groupby requires a pre-sort. chain and islice compose badly without helper functions. Nothing in the standard library lets you write the transformation you actually mean as a readable pipeline.

Three libraries fill that gap, and they are not interchangeable: toolz (5,161 stars, last push 2026-10-07) is a functional standard library built around curried, composable functions. funcy (3,508 stars, 2026-10-26) is an ergonomic grab-bag that reads like Django querysets for plain Python data. more-itertools (4,110 stars, 2026-12-01) is a recipe book — hundreds of iterator utilities that extend itertools rather than replace it. Install the wrong one and you get either a dependency you never call or a pipeline style your team quietly stops using.

TL;DR

Pick toolz if you write data pipelines. pipe, curry, groupby, frequencies, and get_in/assoc_in are the vocabulary you are missing, everything is lazy, and the whole library is small enough to read in an afternoon. Reach for cytoolz (1,115 stars, same API, Cython-compiled) when a hot loop dominates your profile.

Pick more-itertools if your problem is batching, windowing, or iterator plumbing. It is the library you import when you need chunked, windowed, distinct_permutations, peekable, or side_effect — not when you need a programming style.

Pick funcy if you want readable one-liners in application code. flow, walk, select, compact, silent, retry, and a decorator toolbox make Django and FastAPI code shorter without introducing a functional-programming dialect. Use funcy.cache’s ttl_cache and never the unbounded cache on request-scoped arguments.

There is no winner. But there is a wrong pick per project, and it usually shows up as an unused entry in requirements.txt three sprints later.

The comparison table

Dimensiontoolzfuncymore-itertools
GitHub stars5,1613,5084,110
Last push2026-10-072026-10-262026-12-01
LicenseBSD-3-ClauseBSD-3-ClauseMIT
Core abstractionCurried functions + lazy seqsErgonomic helpers over collectionsIterator recipes
LazinessYes — map/filter/take are iteratorsMostly eager, with lazy variants (lazy, takewhile)Yes — everything returns iterators
Pipeline syntaxpipe(x, f, g) / thread_firstflow(x, f, g) / ->-style rpartialManual composition
Dependency weightZero depsZero depsZero deps
Optional acceleratorcytoolz (Cython)NoneNone
Best fitETL, analytics glue, data toolingWeb apps, utility modulesIterator plumbing, batching
Learning costMedium (currying)LowLow, but a big API surface

Decision matrix: match the tool to the task

Use caseChooseWhy
Reshaping records read from an API or CSVtoolzgroupby, frequencies, merge_with, valmap, keyfilter compose without intermediate lists
Hot inner loop over millions of elementscytoolzSame API as toolz with Cython-compiled kernels; measure with pyperf before and after
Batching rows for bulk insertsmore-itertoolschunked(rows, 500) is the whole solution; batched in stdlib 3.12 covers the simple case
Sliding-window feature extractionmore-itertoolswindowed(seq, 3) beats hand-rolled index arithmetic
Django views with lots of for loopsfuncyselect, pluck, walk, compact read like intent, not mechanics
Retry/throttle/cache decoratorsfuncyretry, throttle, ttl_cache, once ship in the box
You publish a library and want minimal surfacetoolz or noneBoth toolz and more-itertools are tiny and stable; adding funcy to a library’s dependency graph is harder to justify
Cross-team codebase, mixed skill levelsmore-itertoolsLeast stylistic intrusion — helpers look like itertools

toolz: the functional standard library Python never shipped

toolz is what you get if you take the itertools recipes, add currying, and give the whole thing consistent semantics. The two functions that change how code reads are curry and pipe.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from toolz import curry, pipe, groupby, frequencies, valmap, get_in, assoc_in
from toolz.curried import map, filter, reduce  # curried variants

orders = [
    {"id": 1, "region": "eu", "total": 120.0, "items": 3},
    {"id": 2, "region": "us", "total": 80.5,  "items": 1},
    {"id": 3, "region": "eu", "total": 45.0,  "items": 7},
]

by_region = groupby("region", orders)          # key as a string, no lambda
revenue = valmap(lambda rows: sum(r["total"] for r in rows), by_region)
print(revenue)  # {'eu': 165.0, 'us': 80.5}

counts = frequencies(o["region"] for o in orders)
print(counts)   # {'eu': 2, 'us': 1}

# Pipelines read top-to-bottom instead of inside-out
total_eur_items = pipe(
    orders,
    filter(lambda o: o["region"] == "eu"),
    map(lambda o: o["items"]),
    sum,
)
print(total_eur_items)  # 10

groupby accepts a string key, which removes the single most common lambda in data code. pipe threads the value through the callables in order, so you read the transformation in the order it happens. curry turns any function into one that can be partially applied, which makes map and filter usable as pipeline stages without lambda noise.

Nested updates are where toolz quietly saves you from a bug class. get_in and assoc_in treat nested dicts as paths:

1
2
3
4
5
6
7
from toolz import get_in, assoc_in, update_in

config = {"db": {"host": "localhost", "pool": {"size": 5}}}
print(get_in(["db", "pool", "size"], config))          # 5
print(get_in(["db", "tls", "ca"], config, default="")) # '' — no KeyError
updated = assoc_in(config, ["db", "pool", "size"], 20) # immutable update
print(get_in(["db", "pool", "size"], updated))         # 20

If you have ever written config.setdefault("db", {}).setdefault("pool", {})["size"] = 20, assoc_in is the replacement. It returns a new structure rather than mutating, which is exactly what you want in code that is shared across threads or cached.

When cytoolz is worth the extra wheel

cytoolz is a Cython port with a deliberate promise: the same API, imported as a drop-in. The mechanical difference is per-element overhead — pure-Python toolz pays interpreter cost on every call, and cytoolz compiles the hot kernels. For glue code over thousands of records, the difference is invisible. For tight loops over tens of millions, it is the difference between a batch job that fits in a window and one that does not.

Two operational caveats matter more than the speedup:

  1. Do not mix imports. import toolz in one module and import cytoolz in another means two separate function objects with incompatible pickling. Standardise on one, and prefer cytoolz only in the modules that need it — or across the whole service if you want simplicity.
  2. Wheels, not source builds. On platforms without a prebuilt wheel, cytoolz compiles at install time and needs a C toolchain. In slim container images that turns into a build failure, not a warning. Pin a wheel-friendly Python version or accept the compiler dependency.

funcy: ergonomics over purity

funcy optimises for how application code actually reads. It gives you flow (the same idea as pipe), plus a set of collection helpers that map almost one-to-one onto the loops you were about to write:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
from funcy import flow, select, pluck, walk_values, compact, group_by, count_by, silent

users = [
    {"name": "Ada",  "active": True,  "plan": "pro", "seats": 4},
    {"name": "Linus","active": False, "plan": "free","seats": 1},
    {"name": "Grace","active": True,  "plan": "pro", "seats": 9},
]

active_names = flow(users, select(lambda u: u["active"]), pluck("name"))
print(list(active_names))          # ['Ada', 'Grace']

seats_by_plan = count_by(lambda u: u["plan"], users)
print(seats_by_plan)               # {'pro': 2, 'free': 1}

plan_seats = walk_values(sum, group_by("plan", users))  # group_by accepts a key string too
print({k: v for k, v in plan_seats.items()})

silent is funcy’s most pragmatic and most dangerous helper: it swallows a specified exception and returns None instead. Used at a genuine boundary — a metrics call, an optional enrichment — it removes boilerplate. Used in business logic, it turns a crash into a None that propagates three layers down. Treat it as a border control, not a control-flow tool.

For caching, funcy ships cache and ttl_cache:

1
2
3
4
5
from funcy import ttl_cache

@ttl_cache(ttl=60)
def exchange_rates(base: str) -> dict:
    return fetch_rates(base)

ttl_cache is per-process and per-argument. That means it does not survive a restart, does not share across workers, and will happily hold the arguments in memory for the TTL window. For anything larger than a few hundred entries, use cachetools or a real Redis layer — the caching-libraries comparison on this site walks through that decision in detail.

more-itertools: the recipe book that replaces your helper module

more-itertools is not a functional-programming framework. It is what your utils/iterators.py would look like if someone maintained it for fifteen years. The headline helpers are the windowing and batching ones, because those are the loops people write incorrectly:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
from more_itertools import chunked, windowed, peekable, side_effect, distinct_permutations

rows = list(range(1, 11))

for batch in chunked(rows, 3):
    bulk_insert(batch)          # [1,2,3], [4,5,6], [7,8,9], [10]

print(list(windowed(rows, 3))[:2])   # [(1,2,3), (2,3,4)]

# Peek before consuming — for parsers that must look ahead one token
it = peekable(iter(rows))
if it.peek() == 1:
    next(it)

# Side effects without breaking the chain
logged = side_effect(print, rows)

Some of these have since landed in the standard library — itertools.pairwise in 3.10, itertools.batched in 3.12 — and that is the right way to read more-itertools in 2026: use stdlib when it covers you, and keep more-itertools for the long tail. chunked handles the ragged final chunk, distinct_permutations skips duplicates without generating them first, peekable and spy solve lookahead, collapse flattens arbitrarily nested iterables, and numeric_range gives you a float-capable, len()-able range object.

The cost is API surface. more-itertools exports well over a hundred names; nobody remembers all of them. Import explicitly (from more_itertools import chunked) rather than star-importing, and expect code review to ask “is that in the stdlib now?” — sometimes it is.

Where each library actually bites

Currying hides arity errors. A curried function called with too few arguments does not raise; it returns another callable. That is the feature, but it means pipe(data, curried_fn) can silently produce a function instead of a value when you forget an argument. Add a type checker run and an assertion in tests rather than relying on runtime feedback.

Pipeline order is a contract. pipe(x, f, g) calls f(x) then g(...). Every stage must accept the threaded value as its first positional argument. A helper written as def normalise(records, field) works; def normalise(field, records) silently produces garbage. Keep pipeline stages small and named.

funcy’s cache holds references. @cache on a method keyed by a large object will keep that object alive for the process lifetime. ttl_cache bounds time, not size. On long-lived workers, that is a slow memory leak that only shows up after a week.

Generator exhaustion is not an error. All three libraries return iterators, and iterators are single-use. Debugging a “missing rows” bug almost always ends at a generator that was consumed once for logging and then iterated again for output. Materialise deliberately (list(...)) at architectural boundaries, not inside loops.

Version drift in more-itertools. Because it tracks the stdlib and deprecates recipes, pinning a major version in requirements.txt prevents surprise signature changes. This is a library where reading the changelog before an upgrade is cheaper than reading a traceback after.

Benchmarks need your data. Published micro-benchmarks comparing these libraries are almost always measuring call overhead on tiny inputs, which is not your workload. Measure with a real payload — the pytest-benchmark, pyperf, and asv comparison on this site covers the harness setup, and it will tell you within minutes whether cytoolz is worth the build complexity for your access pattern.

FAQ

Is toolz still actively maintained in 2026?

Yes. The repository received commits in October 2026, and its practical maintenance guarantee comes from downstream: distributed data tooling depends on toolz semantics, so the API is effectively frozen and stable. Stability, not release cadence, is the value here — a dependency that does not churn is a feature for a library you build on.

Can I use toolz and more-itertools in the same project?

Yes, and many projects do. They have no shared dependencies and no overlapping names in practice: toolz provides curried, higher-order functions and immutable data helpers, while more-itertools provides iterator recipes. Import both explicitly and keep each module’s style consistent so reviewers know which vocabulary to expect.

Does more-itertools replace itertools?

No. It complements it. Several recipes have been promoted into the standard library over time (pairwise in Python 3.10, batched in 3.12), and you should prefer the stdlib version when it exists. more-itertools remains valuable for the recipes the standard library has not adopted — windowed iteration, distinct permutations, lookahead wrappers, and flattening utilities.

Is funcy fast enough for production web traffic?

For request-scoped collection manipulation, yes — the overhead is negligible next to template rendering, database access, and network calls. The exceptions are numeric hot loops and very large collections, where Cython-backed cytoolz or plain numpy will beat any pure-Python helper. Profile first; py-spy will show you whether helper calls register at all.

Which one should a library author depend on?

Prefer more-itertools or toolz, and prefer neither if the standard library covers you. Both are small, permissively licensed, and stylistically neutral. funcy’s value is expressive convenience in application code; pulling that into a published library exports a style choice your users did not make.

What about type hints and static analysis?

All three ship annotations for their public APIs, and modern mypy/pyright handle them without plugins. The friction is currying: partially applied functions are typed as callables, so a missing argument sometimes surfaces as a type error rather than a runtime one — which is exactly what you want, provided you actually run the checker in CI.

For related tooling decisions, see our comparisons of Python caching libraries, data-class libraries, and Python benchmarking harnesses.


💰 想测试你的市场判断力?我用 Polymarket 做预测市场交易——这是全球最大的预测市场平台,从大选结果到技术监管时间线,什么都可以押注。和赌博不同,这是真正的信息市场:你懂的信息越多,胜率越高。我靠预测技术相关事件的走向已经赚了不少。用我的邀请链接注册:Polymarket.com