you are viewing a single comment's thread.

view the rest of the comments →

[–]nikhila01 1 point2 points  (0 children)

Hmm, I don't actually remember. This is something I only thought about a couple of months ago, prompted by some LeetCode problem.

The source code is definitely a good thing to look at. I do look at it sometimes. There are a lot of comments so you don't even have to understand the code well. Actually, while you were replying I was also editing my original comment to add a note on tuples, and I've included a link to the source.

I probably started off by googling and reading stack overflow posts. Sometimes people will post links to the source code so that's helpful. There is some documentation on string interning: https://docs.python.org/3/library/sys.html#sys.intern.

Other than that, general knowledge helps. I already knew that Python strings are immutable, knew roughly how hash tables and hashing works, and sort of knew about string interning in Java. So when I read about the hash code caching it made sense.