Registry / serialization / purify

purify

JSON →
library0.3.0pypypi✓ verified 88d ago

A library for creating Pythonic object-mutator transforms as pure functions. Version 0.3.0 supports Python 3.10–3.14. Current release cadence is irregular.

pip install purify
INSTALL
IMPORT
SIG · PURIFY
P
purify
serializationpythonv0.3.0
Install
1.6s avg
Import
108ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.110s · 17.8MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.106s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

purify
✓ from purify import purify
The main decorator/function is named 'purify'.

Decorate a class with @purify to make all instance methods return new objects instead of mutating the original.

from purify import purify @purify class Person: def __init__(self, name, age): self.name = name self.age = age p = Person('Alice', 30) # Now p.name = 'Alice', p.age = 30 # Under the hood, mutating methods return new instances
Debug
Known issues
breakingPurify 0.3.0 drops support for Python < 3.10. If you are on Python 3.9 or older, pin to <0.3.0.
fix
Upgrade to Python >=3.10 or pin purify<0.3.0.
affects: <0.3.0
gotchaThe @purify decorator only works on classes with a well-defined __init__ that uses simple attribute assignment. Classes with complex initialization or metaclasses may not be supported.
fix
Ensure your class __init__ only sets attributes directly (e.g., self.x = x). Avoid property setters or custom __setattr__.
affects: all
Errors
Common errors & fixes
AttributeError: 'NoneType' object has no attribute 'name'
Calling a mutating method on an instance and expecting the original to change. Because purify returns a new object, the original is unchanged.
fix
Reassign the result: p = p.update_name('Bob') instead of p.update_name('Bob').
TypeError: __init__() should return None, not 'Person'
Attempting to use @purify on a class that already returns a new instance from __init__ or uses a custom __new__. Purify expects __init__ to set attributes only.
fix
Remove any return statements from __init__ and avoid overriding __new__.
ImportError: cannot import name 'purify' from 'purify'
Older versions of purify (pre-0.2.0) had a different module structure. The correct import is 'from purify import purify' (the decorator and the package share the same name).
fix
Use 'from purify import purify' and ensure you have purify >=0.2.0.
Upgrade
Version history
0.3.0latest on PyPI · released Mar 26, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
Resources
purify — pip install purify · libregistry