I'm confused. Hasn't this all been decided by the PEP long ago? On Tue, Feb 18, 2014 at 9:11 AM, Ethan Furman <ethan at stoneleaf.us> wrote: > On 02/15/2014 11:01 AM, Serhiy Storchaka wrote: > >> How Enum items should be pickled, by value or by name? >> >> I think that Enum will be used to collect system-depending constants, so >> the value of AddressFamily.AF_UNIX can be 1 on >> one platform and 2 on other. If pickle enums by value, then pickled >> AddressFamily.AF_INET on on platform can be >> unpickled as AddressFamily.AF_UNIX on other platform. This looks weird >> and contrary to the nature of enums. >> > > There is one more wrinkle to pickling by name (it's actually still there > in pickle by value, just more obvious in pickle by name) -- aliases. It > seems to me the most common scenario to having a name represent different > values on different systems is when on system A they are different, but on > system B they are the same: > > System A: > > class SystemEnum(Enum): > value1 = 1 > value2 = 2 > > System B: > > class SystemEnum(Enum): > value1 = 1 > value2 = 1 > > If you're on system B there is no way to pickle (by name or value) value2 > such that we get value2 back on system A. The only way I know of to make > that work would be to dispense with identity comparison, use the normal == > comparison, and have aliases actually be separate objects (we could still > use singletons, but it would be one per name instead of the current one per > value, and it would also be an implementation detail). > > Thoughts? > > -- > ~Ethan~ > > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > https://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: https://mail.python.org/mailman/options/python-dev/ > guido%40python.org > -- --Guido van Rossum (python.org/~guido) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20140218/815f1477/attachment.html>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4