Expression
Practical functional programming for Python 3.10+
What it is and what it does
Expression is a functional programming library for Python 3.10+ that brings F#-inspired abstractions to Python while staying pragmatic and Pythonic. It provides tools for pipelining (composing functions into workflows), error handling via Option and Result types (enabling railway-oriented programming), immutable collections (Seq, Block, Map), pattern matching, and computational expressions—all with full type hints for static type checking.
The library aims to make functional programming accessible to Python developers without requiring purely functional style or heavy abstraction. It supports both fluent (dot-chaining) and functional (pipe) syntax, allowing developers to choose their preferred style. Core use cases include building composable data transformations, handling optional and error values safely, and structuring workflows with predictable error propagation.
Use it for:
- Build data transformation pipelines by chaining map, filter, and fold operations on sequences.
- Handle optional values and errors safely using Option and Result types instead of None checks and exceptions.
- Compose reusable functions into custom operators for complex workflows.
- Use pattern matching as an alternative to if-elif-else for cleaner control flow.
- Integrate functional types with Pydantic models for type-safe data serialization.
- Implement actor-model concurrency using the Mailbox Processor for lock-free programming.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Expression provides functional programming abstractions for Python, including pipelines, composition, error handling types (Option, Result), immutable collections, and pattern matching support.
Yes, with conditions. Expression is worth installing if you want to adopt functional programming patterns in Python and are willing to require Python 3.10+. The library is stable (Production/Stable status) and permissively licensed. However, the aging maintenance status (541 days since last release) means you should verify that the library's feature set and bug-fix pace meet your project's needs before committing to it as a core dependency.
Install
expression on PyPI
pip
pip install expressionuv
uv add expressionpoetry
poetry add expressionInstalling Expression
Before you install
Low install friction with a single lightweight dependency (typing-extensions). Maintenance status is aging—last release was 541 days ago, though the repository remains active with a recent commit on 2025-03-11 and 766 stars.
License in practice
MIT license permits commercial and private use with minimal restrictions, making it suitable for most projects.
Quickstart
pip install expression
from expression import pipe, Some
from expression.collections import Seq, seq
v = Some(1)
result = v.pipe(lambda x: x.map(lambda y: y + 1))
xs = Seq.of(1, 2, 3)
ys = xs.pipe(seq.map(lambda x: x * 2))
Requires Python 3.10 or later; earlier Python versions are not supported.
Verify before relying
- Whether the library's type inference works reliably with mypy or Pylance in practice for complex pipelines.
- Performance characteristics compared to native Python iteration for large sequences.
- Adoption and community support beyond the 766 GitHub stars.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4,>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — typing-extensions |
| Maintenance | aging — 541 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 5,652,649/month — #2,062 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: expression-5.6.0-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
oslashOSlash implements functional programming…
permissive · top 15,000 on PyPI
wrapsProvides type-safe wrapper types for…
permissive · top 15,000 on PyPI
pipePipe enables shell-like infix syntax for…
permissive · top 15,000 on PyPI
pampyPampy provides pattern matching for Python,…
permissive · top 15,000 on PyPI
sumtypesProvides algebraic data types for Python,…
permissive · top 15,000 on PyPI
lensesLenses provides a functional approach to…
copyleft · top 15,000 on PyPI
funcyFuncy provides a collection of functional…
permissive · top 5,000 on PyPI
common-expression-languageEvaluates Google's Common Expression Language…
permissive · top 15,000 on PyPI
aiostreamaiostream provides composable stream operators…
copyleft · top 5,000 on PyPI
firebird-baseProvides a collection of utility modules for…
permissive · top 15,000 on PyPI