Registry / serialization / serpy
library0.3.1pypypi✓ verified 83d ago

serpy is a fast, simple object serialization library for Python, inspired by Django REST Framework (DRF) serializers but with a focus on speed. Current version is 0.3.1, released in 2018, with no recent updates. It supports Python 2.7 to 3.6 and has a low release cadence.

pip install serpy
INSTALL
IMPORT
SIG · SERPY
S
serpy
serializationpythonv0.3.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

Serializer
from serpy import Serializer
import serpy
Importing `serpy` directly doesn't give you `Serializer`; you need to import the class explicitly.
IntField
from serpy import IntField
from serpy.fields import IntField
Fields are not in a submodule; they are directly in `serpy`.

Define a serializer class and serialize a dictionary or object instance.

import serpy class PersonSerializer(serpy.Serializer): name = serpy.StrField() age = serpy.IntField() person = {'name': 'Alice', 'age': 30} serializer = PersonSerializer(instance=person) result = serializer.data print(result) # {'name': 'Alice', 'age': 30}
Debug
Known issues
breakingUpgrading from 0.1.x to 0.2.0: If `required=False`, `None` values are now dropped from the output. Also, support for Python 2.6 is dropped.
fix
Review serializers that rely on `None` values being present; set `required=True` if you want `None` values included.
affects: 0.1.x -> 0.2.0
breakingIn version 0.3.0, behavior for `required=True` and `required=False` changed to match DRF. Previously, `required=False` might have dropped `None` values; now `None` values are included. Missing keys cause `KeyError` for `required=True`.
fix
Adjust serializers relying on the old behavior: now `None` values are kept regardless of `required`, except when key is missing.
affects: 0.2.x -> 0.3.0
gotchaMethodField catches `AttributeError` and `KeyError` only if the method returns a value; if the method raises those errors for missing attributes, they are not caught and propagate.
fix
Ensure your `MethodField` method does not rely on catching these exceptions implicitly; handle them inside the method.
affects: >=0.3.1
deprecatedThe library is no longer actively maintained; last release was 2018. No support for modern Python (3.7+), including f-strings, type hints, or asyncio.
fix
Consider using `marshmallow` or `pydantic` for ongoing support and modern Python.
affects: all
Errors
Common errors & fixes
AttributeError: module 'serpy' has no attribute 'Serializer'
Importing only `import serpy` without the class.
fix
Use `from serpy import Serializer` or `import serpy; serpy.Serializer`.
TypeError: __init__() got an unexpected keyword argument 'instance'
Using keyword argument `obj` instead of `instance` (changed in 0.1.0).
fix
Use `instance=...` instead of `obj=...`.
KeyError: 'name'
Serializing a dictionary missing a key with `required=True` (default).
fix
Use `required=False` on the field, or ensure the key exists.
Upgrade
Version history
0.3.1latest on PyPI · released Nov 28, 2017
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
serpy — pip install serpy · libregistry