Limit for hashing nested tuples?

Viewed 264

A few lines of code that demonstrates what I'm asking are:

>>> x = ()
>>> for i in range(1000000):
...     x = (x,)


>>> x.__hash__()

=============================== RESTART: Shell ===============================

The 1000000 may be excessive, but it demonstrates that there is some form of limit when hashing nested tuples (and I assume other objects). Just to clarify, I didn't restart the shell, it did that automatically when I attempted the hash.

What I want to know is what is this limit, why does it happen (and why did it not raise an error), and is there a way around it (so that I can put tuples like this into sets or dictionaries).

1 Answers
Related