Fix Python code style
Python idiom: reimplement hash and eq