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 intent
One-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:
AutoSerializer preserves sets through cache roundtrip ✓
AutoSerializer does NOT preserve tuples through cache roundtrip ✗ (same MessagePack issue as default)
- ~10 LOC fix in
auto_serializer.py
References: #73
Description
Two related improvements to the serializer system:
1. Add
serializer='pythonic'alias forAutoSerializerautois vague — "auto-detect what?"pythoniccommunicates the value: preserves Python-native types.One-line change in
SERIALIZER_REGISTRY:2. Add tuple preservation to AutoSerializer
AutoSerializeralready preserves sets and frozensets via type markers ({"__set__": True, ...}). Tuples need the same treatment:Why
serializer='auto'(or'pythonic') would then preserve tuples, sets, frozensets, datetime, UUID, Decimalserializer='default'stays MessagePack for cross-SDK compatibilitypythonic= Python-only type fidelity,default= cross-language safeEvidence
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)auto_serializer.pyReferences: #73