purify
Pythonic object-mutator transforms as pure functions
Decision gist · record as of 2026-08-14
Yes, if you regularly write object-transform functions and want to enforce purity without deep-copy overhead. The package is actively maintained, has no dependencies, and works on current Python versions. It's a narrow but well-defined tool—install it when you recognize the pattern it solves in your own code, not as a general utility.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction: pure Python, no runtime dependencies, and supports modern Python versions 3.10 through 3.14.
- Repository is active with recent commits.
License · maintenance · safety
permissive license (permissive) — Apache License 2.0 is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
last release 2026-03-26 (141 days) · last repo commit 2026-03-26 · 3 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 120,297 downloads/mo, #12,034 on PyPI
Alternatives
Verify before relying
pip install purify
from purify import purify
@purify
def rename_tree(name: str, tree):
tree.name = name
return tree
original = Tree('Old')
modified = rename_tree('New', original)
# original.name is still 'Old', modified.name is 'New'- Whether the shallow-copy approach is sufficient for nested mutable structures in typical use cases beyond the documented examples
- Performance characteristics and memory overhead compared to standard mutation in real-world codebases
What it is and what it does
Purify is a decorator that solves a common Python pattern problem: writing functions that transform objects while maintaining functional purity. Normally, Python encourages mutating an object in place and returning it for efficiency, but this breaks referential transparency when the original object is needed elsewhere. Deepcopy is the pure alternative but is orders of magnitude slower. Purify uses shallow copy by default, making the decorated function pure without the performance cost of deep copying.
The decorator works by automatically shallow-copying the target argument before the function executes, so mutations inside the function only affect the copy. You specify which argument to copy either by position (last argument by default) or by name. For complex nested structures, the documentation recommends decomposing your transforms into multiple shallow-copy layers rather than using deep copy, which often yields both purer and more reusable functions.
Use it for
- Transform tree or graph structures where you need the original unchanged but want to write natural mutation-style code
- Build pipelines of object modifications where intermediate results must not affect earlier stages
- Write testable functions that don't have hidden side effects on their inputs
- Refactor existing mutation-based codebases toward functional style without rewriting to use expensive deepcopy
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you regularly write object-transform functions and want to enforce purity without deep-copy overhead.
The package is actively maintained, has no dependencies, and works on current Python versions. It's a narrow but well-defined tool—install it when you recognize the pattern it solves in your own code, not as a general utility.
Install
purify on PyPI
Before you install
Low friction: pure Python, no runtime dependencies, and supports modern Python versions 3.10 through 3.14. Repository is active with recent commits.
License in practice
Apache License 2.0 is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install purify
from purify import purify
@purify
def rename_tree(name: str, tree):
tree.name = name
return tree
original = Tree('Old')
modified = rename_tree('New', original)
# original.name is still 'Old', modified.name is 'New'
Verify before relying
- Whether the shallow-copy approach is sufficient for nested mutable structures in typical use cases beyond the documented examples
- Performance characteristics and memory overhead compared to standard mutation in real-world codebases
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release <3.15,>=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 141 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 120,297 / month, #12,034 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14 |
Evidence: purify-0.3.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “pure function decorator python”
- purifyA decorator that makes object-mutating functions pure by…
- cachettlcachettl provides LRU TTL cache decorators for both synchronous and…
- ratelimRatelim enforces rate limits on function calls by decorating them to…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also decopatch · lenses · legacy-api-wrap · wrapt · mutmut · flake8-functions · makefun · ConfigUpdater · singleton-decorator · decorator