[Python-Dev] Pickling of Enums
Guido van Rossum
guido at python.org
Tue Feb 18 19:05:51 CET 2014
Hm. But there's an implementation that has made it unscathed through
several betas and an RC. AFAICT that beta pickles enums by value. And I
happen to think that that is the better choice (but I don't have time to
explain this gut feeling until after 3.4 has been released).
On Tue, Feb 18, 2014 at 10:01 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
> On 02/18/2014 09:47 AM, Guido van Rossum wrote:
>> I'm confused. Hasn't this all been decided by the PEP long ago?
> The PEP only mentions pickling briefly, as in "the normal rules apply".
> How pickling occurs is an implementation detail, and it turns out that
> pickling by name is more robust.
> Serhiy, as part of his argument for using the _name_ instead of the
> _value_ for pickling, brought up the point that different systems could
> have different values for the same name. If true in practice (and I
> believe it is) this raises the issue of aliases, which currently *cannot*
> be pickled by name because there is no distinct object for the alias. If
> you ask for Color['alias_for_red'] you'll get Color.red instead.
> Using identity comparison was part of the PEP.
> I guess the question is which is more important? Identity comparison or
> this (probably) rare use-case? If we stick with identity I'm not aware of
> any work-around for pickling enum members that are aliases on one system,
> but distinct on another.
> I've been talking about pickling specifically, but this applies to any
> serialization method.
> Python-Dev mailing list
> Python-Dev at python.org
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev