Updates:
        Status: WorkingAsIntended

Comment #1 on issue 274 by liuj...@google.com: Python generated protobufs are not hashable in 2.4.0a
http://code.google.com/p/protobuf/issues/detail?id=274

Sorry we didn't mention this in document. Quote from our internal change log:

        Python proto2 API protobufs are no longer hashable.

They previously inherited object.__hash__(), which is not consistent with their custom __eq__() and __ne__() methods. This is a simple fix. Any code broken by this change was already broken in a more subtle manner.

If you want sets or mappings of protobufs, use their SerializePartialToString() output, which /should/ be deterministic and consistent for any particular build of a binary/PAR. Only use actual SerializePartialToString() output however, _not_ pre-encoded protobufs read from the disk/wire/etc! They may not be encoded consistently, so parse and then re-encode them to be safe.

A proper __hash__() method for protobufs, consistent with __eq__() and __ne__(), could be implemented in the future. It would have the caveat that profobufs must not be modified while in use as keys. Given that restriction, it might be best to leave protobufs as unhashable.


--
You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to