Skip to main content

pipette

pipette is a lightweight, expressive Python library designed to enable clean, functional-style data processing pipelines with intuitive syntax and powerful composition.

Note that due to the limitations of Python's static typing, some features may not provide type hints as expected. However, the library is designed to be flexible and easy to use, even without strict type enforcement.


Features

pipette is currently in early development, but it already includes:

  • Lazy evaluation for efficient data processing.
  • Support for custom transformations using the @pipette decorator.
  • Core functional utilities like select, where, reduce, sort_by, and more.
  • Currying support for partial function application.
  • Basic monad implementation for chaining operations with error handling.

Installation

pipette can be installed via pip from the Python Package Index (PyPI):

pip install pipette-fp

Alternatively, you can install the latest development version of pipette directly from GitHub:

pip install git+https://github.com/chriso345/pipette

Usage

pipette aims to make functional pipelines clear and concise.

from pipette import where, select, into

data = [
    {"active": True, "value": 10},
    {"active": False, "value": 5},
    {"active": True, "value": 7},
]

result = (
    data
    | where(lambda x: x["active"])
    | select(lambda x: x["value"])
    | into(list)
)

print(result)  # Output: [10, 7]

Custom transformations can easily be added to extend functionality:

from pipette import pipette

@pipette
def double(x):
    return builtins.map(lambda n: n * 2, x)

result = (
    [1, 2, 3, 4]
    | double
    | into(list)
)

print(result)  # Output: [2, 4, 6, 8]

Curry

pipette provides a submodule for easy currying of functions:

from pipette.curry import curry

@curry
def add(x: int, y: int) -> int:
    return x + y

result = add(2)(3)
print(result) # Output: 5

result = add(2)
print(result(3)) # Output: 5

Note, however, that python's static typing does not support currying and the type hints will error.

Monads

pipette also includes a simple monad implementation for chaining operations:

from pipette.monad import Maybe, Some, Nothing

def safe_divide(x, y) -> Maybe[float]:
    if y == 0:
        return Nothing()
    else:
        return Some(x / y)

s = Some(10) >> (lambda x: safe_divide(x, 2)) | (lambda x: x + 1)
print(s) # Output: Some(6.0)

n = Some(10) >> (lambda x: safe_divide(x, 0)) | (lambda x: x + 1)
print(n) # Output: Nothing

Here >> binds the monad value to the function, and | provides a simple way to map the result to another function.


License

This project is licensed under the MIT License. See the LICENSE file for details.

Metadata

Release files for pipette-fp 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pipette-fp 1.0.0
File Size Uploaded
pipette_fp-1.0.0.tar.gz 8.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pipette-fp 1.0.0
File Interpreter ABI Platform
pipette_fp-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.0 kB

Release files / pipette_fp-1.0.0.tar.gz

Download URL pipette_fp-1.0.0.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e1afecb0eb8555a298e4eb27957c18a33ca8a3729124a681da5ffa40d5e96abf
BLAKE2b-256 checksum
How to use checksums
4fc658987766a51ba9c71030b330ea6a31c414d5648472a0dd8f1bd59b67a57e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.2

Release files / pipette_fp-1.0.0-py3-none-any.whl

Download URL pipette_fp-1.0.0-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a2006f86d63be63fe22c36e0a2564b3066180cabe6caeb083d0cab9010b540d
BLAKE2b-256 checksum
How to use checksums
a655a7893c2075cb816e5dfdb970caac9d6690c6a065d07af161a610b605ce88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.2

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page