hynek / pem

PEM file parsing in Python.
https://pem.readthedocs.io/
MIT License
159 stars 37 forks source link

Implement __eq__ for PEM objects #22

Closed mithrandi closed 8 years ago

mithrandi commented 8 years ago

Being able to compare these for equality would make my tests simpler, among other things. I guess there's no reason not to implement __hash__ at the same time?

hynek commented 8 years ago

My understanding is that if one implements eq, hash should always be implemented along with it.

mithrandi commented 8 years ago

I think it's the other way around: hashable objects must be comparable for equality, but objects comparable for equality do not necessarily need to be hashable. In particular mutable objects should not be hashable, but they can be comparable (eg. list).

hynek commented 8 years ago

Right. PEM objects should be both.

mithrandi commented 8 years ago

I have a branch mostly done for this, but I'll wait until #24 is merged to PR it since there will be a bunch of stupid conflicts otherwise.