Follow

TIL: generators and zips are hashable but mutable. The hashcode doesn't include the state (which can be modified by calling next).

>>> z=zip([1, 2, 3], [4, 5, 6])

>>> id(z)
4477009472

>>> next(z)
(1, 4)

>>> id(z)
4477009472

@peterdrake this is quite interesting. I bet there’s a good story behind this that lead you to discover this

@ellisvalentiner I was just staring at this diagram I drew a while ago and thought, "Wait, how can generators and zips be hashable?"

qoto.org/@peterdrake/109255444

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.