{"id":1439,"library":"cytoolz","title":"cytoolz Library","description":"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.","status":"active","version":"1.1.0","language":"python","source_language":"en","source_url":"https://github.com/pytoolz/cytoolz","tags":["functional programming","performance","utilities","Cython","toolz"],"install":[{"cmd":"pip install cytoolz","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"cytoolz is a Cythonized implementation of toolz primitives and explicitly lists toolz as a runtime dependency. Some utilities are still provided by the toolz library.","package":"toolz","optional":false}],"imports":[{"symbol":"compose","correct":"from cytoolz.functoolz import compose"},{"symbol":"pipe","correct":"from cytoolz.functoolz import pipe"},{"symbol":"map","correct":"from cytoolz.itertoolz import map"},{"symbol":"groupby","correct":"from cytoolz.itertoolz import groupby"},{"note":"Functions are typically exposed via submodules like `functoolz`, `itertoolz`, `dicttoolz`.","wrong":"import cytoolz.get_in","symbol":"get_in","correct":"from cytoolz.dicttoolz import get_in"}],"quickstart":{"code":"from cytoolz.functoolz import compose, pipe\nfrom cytoolz.itertoolz import map, filter\n\ndef add_one(x):\n    return x + 1\n\ndef multiply_by_two(x):\n    return x * 2\n\ndef is_even(x):\n    return x % 2 == 0\n\n# Example 1: Compose functions\nprocess = compose(multiply_by_two, add_one)\nresult_compose = process(5) # (5 + 1) * 2 = 12\nprint(f\"Compose result: {result_compose}\")\n\n# Example 2: Pipe data through functions\nresult_pipe = pipe(5, add_one, multiply_by_two)\nprint(f\"Pipe result: {result_pipe}\")\n\n# Example 3: Map and filter with cytoolz iterators\nnumbers = [1, 2, 3, 4, 5, 6]\nprocessed_numbers = list(filter(is_even, map(add_one, numbers)))\nprint(f\"Processed numbers (map/filter): {processed_numbers}\") # [4, 6, 8]\n","lang":"python","description":"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."},"warnings":[{"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.","message":"Performance 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.","severity":"gotcha","affected_versions":"All"},{"fix":"Refer to the official `toolz` documentation for the primary source of API information. Monitor `toolz` release notes for breaking changes when upgrading.","message":"`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.","severity":"gotcha","affected_versions":"All"},{"fix":"Always ensure `pip install cytoolz` is sufficient, as it should pull in `toolz` automatically. If issues arise, explicitly install `toolz` (`pip install toolz`).","message":"`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.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"search_vec":"'1.1.0':46 'cadenc':48 'common':30 'composit':38 'current':43 'cython':10,64 'cython-impl':9 'cytoolz':1,3 'drop':25 'drop-in':24 'focus':34 'follow':50 'found':17 'function':15,32,60 'general':49 'high':7 'high-perform':6 'implement':11 'improv':41 'iter':36 'librari':2,21,59 'mani':29 'offer':23 'perform':8,62 'primarili':33 'program':61 'provid':4 'releas':47,54 'replac':27 'signific':51 'speed':40 'toolz':20,31,58,65 'updat':52 'upstream':57 'util':16,63 'version':12,44","created_at":"2026-04-09T03:47:59.527660+00:00","updated_at":"2026-04-16T04:45:33.787276+00:00","problems":[{"fix":"Ensure `cytoolz` is installed by running: `pip install cytoolz`","cause":"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.","error":"ModuleNotFoundError: No module named 'cytoolz'"},{"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`.","cause":"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.","error":"ERROR: Command errored out with exit status 1: command: ... Failed building wheel for cytoolz"},{"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).","cause":"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`.","error":"ModuleNotFoundError: No module named 'cytoolz.itertoolz'"},{"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.","cause":"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.","error":"'cytoolz.functoolz.Compose' object has no attribute '__module__'"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.1.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/pytoolz/cytoolz","docs":"https://toolz.readthedocs.io/en/latest/","changelog":"https://github.com/pytoolz/cytoolz/releases","pypi":"https://pypi.org/project/cytoolz/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-28","install_tag":"verified"}}