[Python-ideas] Enum and serialization

Ethan Furman ethan at stoneleaf.us
Fri Jul 19 02:01:31 CEST 2013


On 07/18/2013 04:54 PM, Giampaolo Rodola' wrote:
> On Thu, Jul 18, 2013 at 8:24 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
>> See http://bugs.python.org/issue18264.
>
> Oh, OK. Glad to see this is being tracked.
>
>> The basic issue is that json only knows how to serialize built-in types.  As
>> soon as we build on that, json barfs.
>>
>> One way around that is to write your own json handler that knows about your
>> custom types.
>>
>> For the 3.4 stdlib there are two proposals on the table:
>>
>>    1) for IntEnum and FloatEnum cast the member to int or float, then
>> procede;
>>
>>    2) for any Enum, extract the value and proceed.
>
> What about third party serialization libs though?

They are in the same boat, and have the same options.

Short of defining a new protocol, I don't think there's much we can do for other serialization libs, besides making it 
easy for them to do the same thing we are.

--
~Ethan~


More information about the Python-ideas mailing list