What happens when you call `if key in dict`

前端 未结 3 895
旧时难觅i
旧时难觅i 2020-12-11 06:05

I have a class (let\'s call it myClass) that implements both __hash__ and __eq__. I also have a dict that maps myCl

3条回答
  •  悲&欢浪女
    2020-12-11 06:27

    __hash__ defines the bucket the object is put into, __eq__ gets called only when objects are in the same bucket.

提交回复
热议问题