{"id":6050,"library":"pyfunctional","title":"PyFunctional","description":"PyFunctional is a Python package designed for creating data pipelines using a functional programming paradigm, inspired by Scala and Spark. It provides tools for chaining operations on sequences, supporting lazy evaluation, parallel processing, and various data transformations. The current version is 1.5.0, and the project generally focuses on API stability since its 1.0.0 release.","status":"active","version":"1.5.0","language":"python","source_language":"en","source_url":"https://github.com/EntilZha/PyFunctional","tags":["functional programming","data pipelines","lazy evaluation","chaining","scala","spark"],"install":[{"cmd":"pip install pyfunctional","lang":"bash","label":"Install PyFunctional"}],"dependencies":[],"imports":[{"note":"Use `seq` for standard, lazy functional pipelines.","symbol":"seq","correct":"from functional import seq"},{"note":"Use `pseq` for pipelines that automatically leverage parallel processing for performance.","symbol":"pseq","correct":"from functional import pseq"}],"quickstart":{"code":"from functional import seq\n\n# Create a sequence from a range of numbers\nresult = seq(range(10))\n    .map(lambda x: x * x) # Square each number\n    .filter(lambda x: x > 10) # Keep numbers greater than 10\n    .reduce(lambda x, y: x + y, 0) # Sum the remaining numbers, starting with 0\n\nprint(result)\n# Expected output: 285","lang":"python","description":"This example demonstrates creating a sequence, applying common functional transformations like `map` and `filter`, and finally aggregating results with `reduce`."},"warnings":[{"fix":"Update `pip install scalafunctional` to `pip install pyfunctional` and change `from scalafunctional import ...` to `from functional import ...`.","message":"The library was renamed from `ScalaFunctional` to `PyFunctional` in version 0.6.0. Projects using the old package name will need to update their `install_requires` and import paths.","severity":"breaking","affected_versions":"<0.6.0"},{"fix":"Replace calls to `Sequence.zip_with_index()` with Python's built-in `enumerate()` for equivalent functionality.","message":"The behavior of `Sequence.zip_with_index` was modified in version 0.5.0. It no longer behaves as expected in previous versions and should be replaced.","severity":"breaking","affected_versions":"<0.5.0"},{"fix":"To force immediate evaluation for debugging or specific needs, append an action like `.to_list()` or `.to_dict()` at the point where you need the results.","message":"Starting from version 0.3.0, all operations in PyFunctional are lazy by default. This means transformations are not executed until an action (like `reduce`, `to_list`, `to_dict`, or iteration) consumes the sequence. This can lead to unexpected behavior if intermediate results are expected to be immediately available or if debugging relies on immediate evaluation.","severity":"gotcha","affected_versions":">=0.3.0"},{"fix":"If your pipeline operations are CPU-bound and you want to leverage multiple cores, ensure your pipeline starts with `from functional import pseq` and use `pseq(...)`.","message":"For automatic parallelization of pipeline operations (e.g., `map`, `filter`), you must explicitly import and use `pseq` instead of `seq`. `seq` does not use parallel processing.","severity":"gotcha","affected_versions":">=0.7.0"}],"env_vars":null,"search_vec":"'1.0.0':54 '1.5.0':43 'api':50 'chain':26,62 'creat':9 'current':40 'data':10,37,58 'design':7 'evalu':32,61 'focus':48 'function':14,56 'general':47 'inspir':17 'lazi':31,60 'oper':27 'packag':6 'paradigm':16 'parallel':33 'pipelin':11,59 'process':34 'program':15,57 'project':46 'provid':23 'pyfunct':1,2 'python':5 'releas':55 'scala':19,63 'sequenc':29 'sinc':52 'spark':21,64 'stabil':51 'support':30 'tool':24 'transform':38 'use':12 'various':36 'version':41","created_at":"2026-04-14T18:39:46.847079+00:00","updated_at":"2026-04-16T18:27:21.512595+00:00","problems":[{"fix":"Ensure that any functions used with `pseq` are defined within the `if __name__ == '__main__':` block in your main script, or are imported from a separate module that can be safely imported by worker processes. For `lambda` functions, consider defining them as top-level `def` functions if they need to be serialized across processes.","cause":"When using `pseq` (parallel sequence) with Python's `multiprocessing` module on Windows, functions (especially `lambda` functions or module-level functions not protected by `if __name__ == '__main__':`) are not correctly serialized and made available to child processes, leading to a `NameError` in the worker processes.","error":"NameError: name 'my_function' is not defined (when using pseq on Windows)"},{"fix":"To force the execution of the pipeline and get the results, append an action method to the end of your functional chain, such as `.to_list()`, `.to_dict()`, `.reduce()`, or iterate over the `seq` object.","cause":"PyFunctional operations are designed to be lazy by default, meaning transformations like `map` and `filter` are not executed immediately. They only run when an 'action' (like `to_list()`, `reduce()`, `first()`, `all()`, or iterating over the sequence) is called to consume the results.","error":"My PyFunctional chain isn't executing/producing output (lazy evaluation)"},{"fix":"Review the type of the object at the point the `TypeError` is raised. Ensure that functions passed to `map`, `filter`, or other transformation methods are indeed callable, and that the arguments they receive are of the expected type. Also, ensure the input to `seq()` is an iterable.","cause":"This common Python error occurs when you try to call a variable or an object as if it were a function, but its type does not support being called. This can happen in PyFunctional if a chained operation returns a non-callable object (e.g., a simple data type) and the next operation in the chain implicitly tries to call it, or if `seq` is initialized with a non-iterable type.","error":"TypeError: '...' object is not callable"},{"fix":"To fix `ModuleNotFoundError`, install the package using `pip install pyfunctional`. To fix `AttributeError` for `seq` or `pseq`, ensure you are using the correct import statement: `from functional import seq` for standard pipelines or `from functional import pseq` for parallel processing.","cause":"The `ModuleNotFoundError` indicates that the `pyfunctional` package is not installed or not accessible in your Python environment. The `AttributeError` typically means that while the `functional` module might be found, the specific `seq` object (or `pseq`) is not being imported correctly or is not directly exposed as an attribute of the top-level `functional` module if a different import style is used.","error":"ModuleNotFoundError: No module named 'functional' or AttributeError: module 'functional' has no attribute 'seq'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.5.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/EntilZha/PyFunctional","docs":"https://docs.pyfunctional.pedro.ai/en/master/","changelog":null,"pypi":"https://pypi.org/project/pyfunctional/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data","workflow"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}