擅长:python、mysql、java
<p>您不需要重写<code>__hash__</code>来比较两个对象(如果需要自定义哈希,即为了提高插入到集合或字典中的性能,就需要重写)。在</p>
<p>此外,这里还有无限递归:</p>
<pre>
def __eq__(self, other):
if (other == self):
return True
if isinstance(other, RegionalCustomerCollection):
return self.region_accountids == other.region_accountids
return False
</pre>
<p>如果两个对象都是<code>RegionalCustomerCollection</code>类型,那么自从<code>==</code>调用<code>__eq__</code>之后,将有无限递归。在</p>