--- id: pampy version: "0.3.0" license: unclear license_treatment: permissive maintenance: dormant --- # pampy — The Pattern Matching for Python you always dreamed of License: permissive · Maintenance: dormant · Downloads: 85.3K/mo ## What it is and what it does Pampy is a lightweight pattern-matching library that lets you write declarative match expressions instead of nested conditionals. It supports matching literals, types, tuples, lists, dicts, dataclasses, and typing annotations, with the special operator `_` capturing values to pass into handler functions. Patterns are evaluated in order, and you can nest structures arbitrarily—matching a tuple of integers, a dict with specific keys, or a dataclass field all work the same way. The library is pure Python with no dependencies, making it trivial to install and use. It's useful for simplifying control flow in recursive algorithms, AST walkers, or any code that needs to branch on the shape of data. However, since the last release was in 2019 and the repository shows no active maintenance, you should verify compatibility with your target Python version before adopting it in new projects. Use it for: - Simplify recursive algorithms like Fibonacci or tree traversal by matching on input structure instead of writing nested conditionals. - Parse and evaluate Lisp-like expressions or simple DSLs by matching on callable, tuple, and type patterns. - Destructure nested dicts and lists to extract values without repeated indexing or get() calls. - Dispatch on class hierarchies (e.g., different Pet subclasses) without isinstance chains. - Validate and extract fields from dataclasses or typed tuples in a single match expression. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Pampy provides pattern matching for Python, letting you write match expressions that destructure and dispatch on values, types, and nested structures without nested if-else chains. Yes, if you need pattern matching and are comfortable with a dormant library. The package is tiny, has no dependencies, carries no known vulnerabilities, and works well for the specific task it solves. Install it for algorithmic code, DSL parsing, or data destructuring where it genuinely improves readability. Avoid it if you require active maintenance or have not tested it with your target Python version. ## Install pip install pampy uv add pampy poetry add pampy ## Installing pampy Before you install: Installation is frictionless—a pure-Python wheel with no runtime dependencies. The package is dormant (last release November 2019, last commit January 2025), so it receives no active maintenance, but the small codebase (150 lines) and lack of external dependencies mean there is little surface for breakage. License in practice: Licensed under MIT (permissive), so you can use, modify, and distribute this package freely in commercial and open-source projects with minimal restrictions. Quickstart: from pampy import match, _ def fibonacci(n): return match(n, 1, 1, 2, 1, _, lambda x: fibonacci(x-1) + fibonacci(x-2) ) fibonacci(5) # => 5 Requires Python >3.6; dict-based patterns with `_` as keys rely on insertion-order guarantees. Verify before relying: - Whether the dormant status and 2019 release date pose compatibility risks with recent Python versions. - Performance characteristics compared to native match statements or other pattern-matching libraries. - Actual minimum Python version needed for all features to work correctly. ## Package facts - License: not declared (permissive) - Python support: supports_current - Install friction: low - Maintenance: dormant - Downloads: 85.3K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags pattern matching python, match expression destructuring, functional pattern matching, switch case alternative, type-based dispatch, structural pattern matching, match statement library, pattern-matching, functional-programming, control-flow [View on SkillFed](https://skillfed.io/packages/pampy) · [View on PyPI](https://pypi.org/project/pampy/)