nginxinc / crossplane

Quick and reliable way to convert NGINX configurations into JSON and back.
Apache License 2.0
719 stars 87 forks source link

Object hashing and equality operations #29

Closed gshulegaard closed 6 years ago

gshulegaard commented 6 years ago
aluttik commented 6 years ago

I'm confused as to why you'd want a __hash__ method if you have an __eq__ method. The only purpose I can think of is so that you can insert CrossplaneObjects into sets/dicts, but you really shouldn't do that anyway since they're mutable objects.

Here's an exerpt from the Python docs:

If a class defines mutable objects and implements an __eq__() method, it should not implement __hash__(), since the implementation of hashable collections requires that a key’s hash value is immutable (if the object’s hash value changes, it will be in the wrong hash bucket).

https://docs.python.org/3.6/reference/datamodel.html#object.__hash__

aluttik commented 6 years ago

We have decided to remove all of this object-oriented stuff before the next version of crossplane is released.