Registry / data / cytoolz

cytoolz

JSON →
library1.1.0pypypi✓ verified 30d ago

cytoolz provides a high-performance, Cython-implemented version of the functional utilities found in the toolz library. It offers drop-in replacements for many common `toolz` functions, primarily focusing on iteration and composition for speed improvements. The current version is 1.1.0. Release cadence generally follows significant updates or releases of the upstream `toolz` library.

pip install cytoolz
INSTALL
IMPORT
SIG · CYTOOLZ
C
cytoolz
datapythonv1.1.0
Install
1.9s avg
Import
63ms
Disk
28MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.066s · 28.8MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.9s · import 0.060s · 31MB
28MB installed
● package 28MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

compose
✓ from cytoolz.functoolz import compose
pipe
✓ from cytoolz.functoolz import pipe
map
✓ from cytoolz.itertoolz import map
groupby
✓ from cytoolz.itertoolz import groupby
get_in
✓ from cytoolz.dicttoolz import get_in
✗ import cytoolz.get_in
Functions are typically exposed via submodules like `functoolz`, `itertoolz`, `dicttoolz`.

This quickstart demonstrates basic usage of `compose`, `pipe`, `map`, and `filter` from `cytoolz.functoolz` and `cytoolz.itertoolz`. These functions provide a functional programming style with potential performance benefits over their pure Python equivalents, especially for iterable operations.

from cytoolz.functoolz import compose, pipe from cytoolz.itertoolz import map, filter def add_one(x): return x + 1 def multiply_by_two(x): return x * 2 def is_even(x): return x % 2 == 0 # Example 1: Compose functions process = compose(multiply_by_two, add_one) result_compose = process(5) # (5 + 1) * 2 = 12 print(f"Compose result: {result_compose}") # Example 2: Pipe data through functions result_pipe = pipe(5, add_one, multiply_by_two) print(f"Pipe result: {result_pipe}") # Example 3: Map and filter with cytoolz iterators numbers = [1, 2, 3, 4, 5, 6] processed_numbers = list(filter(is_even, map(add_one, numbers))) print(f"Processed numbers (map/filter): {processed_numbers}") # [4, 6, 8]
Debug
Known issues
gotchaPerformance benefits are not universal. While `cytoolz` offers significant speedups for many iterative and compositional operations, particularly those involving loops, simple function calls or operations already highly optimized in CPython might not see major gains, and could even incur minor overhead due to C-Python bridge calls. Measure performance in your specific use case.
fix
Profile your application to determine if `cytoolz` provides a meaningful performance improvement for your specific bottlenecks. Don't assume all functions will be faster.
affects: All
gotcha`cytoolz`'s API mirrors `toolz`. `cytoolz` aims to be a drop-in replacement for `toolz` primitives. Therefore, users should consult the `toolz` documentation for specific API details (function signatures, available utilities). Changes in `toolz`'s API (e.g., removals, argument changes) will generally apply to `cytoolz` as well.
fix
Refer to the official `toolz` documentation for the primary source of API information. Monitor `toolz` release notes for breaking changes when upgrading.
affects: All
gotcha`toolz` is a required runtime dependency. Despite `cytoolz` providing Cythonized versions of many `toolz` functions, the `toolz` library itself is an explicit and necessary dependency. Ensure both `cytoolz` and `toolz` are installed in your environment.
fix
Always ensure `pip install cytoolz` is sufficient, as it should pull in `toolz` automatically. If issues arise, explicitly install `toolz` (`pip install toolz`).
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'cytoolz'
This error occurs when the `cytoolz` package is not installed in the Python environment or the environment where the code is being run is not the one where `cytoolz` was installed.
fix
Ensure `cytoolz` is installed by running: `pip install cytoolz`
ERROR: Command errored out with exit status 1: command: ... Failed building wheel for cytoolz
This installation error typically indicates that your system lacks the necessary C compiler or Python development headers to compile the Cython components of `cytoolz` during installation. It can also occur with specific Python versions (e.g., Python 3.10 initially had issues) or when `Cython` itself is not pre-installed.
fix
First, ensure you have a C compiler (like build-essential on Linux, Xcode command line tools on macOS, or Visual C++ build tools on Windows). Then, try installing `Cython` separately before `cytoolz`: `pip install cython` followed by `pip install cytoolz`.
ModuleNotFoundError: No module named 'cytoolz.itertoolz'
This error often arises in deployment scenarios (e.g., PyInstaller, Zappa, AWS Lambda) or when `cytoolz` is bundled in a zip file, because the Python interpreter cannot properly locate and load the Cython-compiled submodules like `itertoolz` or `functoolz`.
fix
When using tools like PyInstaller, you might need to add hidden imports (e.g., `--hidden-import=cytoolz.itertoolz`). For deployment to environments like AWS Lambda or when using zip files, ensure that the compiled `.so` or `.pyd` files for the Cython modules are correctly packaged and accessible in the Python path, often by building the deployment package in a compatible environment (e.g., a Docker container simulating the target Lambda environment).
'cytoolz.functoolz.Compose' object has no attribute '__module__'
This `AttributeError` can occur when code expects the `Compose` object (returned by `cytoolz.functoolz.compose`) to have a `__module__` attribute, which might be present in the pure Python `toolz` equivalent but not consistently exposed by the Cython implementation.
fix
If this error originates from a third-party library, check if there's an updated version that's compatible with `cytoolz`. If you have control over the code, you might need to adapt it not to rely on the `__module__` attribute of `Compose` objects from `cytoolz` or implement a workaround to provide this attribute if absolutely necessary.
Upgrade
Version history
1.1.0latest on PyPI · released Oct 19, 2025
Audit
Dependencies
toolzrequiredcytoolz is a Cythonized implementation of toolz primitives and explicitly lists toolz as a runtime dependency. Some utilities are still provided by the toolz library.
Agent activity
20 hits · last 30 days
node
18
OpenAI (training)
1
Resources
cytoolz — pip install cytoolz · libregistry