-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Description
Two related improvements to the serializer system:
1. Add serializer='pythonic' alias for AutoSerializer
auto is vague — "auto-detect what?" pythonic communicates the value: preserves Python-native types.
# Current
@cache(serializer='auto')
# Proposed alias
@cache(serializer='pythonic') # clearer intentOne-line change in SERIALIZER_REGISTRY:
SERIALIZER_REGISTRY = {
"auto": AutoSerializer,
"pythonic": AutoSerializer, # alias — preserves Python types
...
}2. Add tuple preservation to AutoSerializer
AutoSerializer already preserves sets and frozensets via type markers ({"__set__": True, ...}). Tuples need the same treatment:
# In _auto_default():
if isinstance(obj, tuple):
return {"__tuple__": True, "value": list(obj)}
# In _auto_object_hook():
if obj.get("__tuple__") is True:
return tuple(obj["value"])Why
- Sets are preserved, tuples are not — inconsistent
serializer='auto'(or'pythonic') would then preserve tuples, sets, frozensets, datetime, UUID, Decimal- Default
serializer='default'stays MessagePack for cross-SDK compatibility - The tradeoff is explicit:
pythonic= Python-only type fidelity,default= cross-language safe
Evidence
From tests/competitive/test_head_to_head.py:
AutoSerializerpreserves sets through cache roundtrip ✓AutoSerializerdoes NOT preserve tuples through cache roundtrip ✗ (same MessagePack issue as default)- ~10 LOC fix in
auto_serializer.py
References: #73
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels