I'm curious about the implementation of dictionary in python. I'm learning about hash tables in my computer science course, and I'm aware that the dictionary data structure in python works as a hash table.
What I haven't worked out is this: what determines the number of buckets in the hash table? I'm asking this about python dictionary in particular, although I'd be interested in other cases as well.
Thanks,
Erik
Top comments (5)
I don't have a link at the moment, but I vaguely remember some Python core contributors doing deep dives into code on video quite a while back. That may not be helpful. 🤷🏽♂️ I'll see if I can find it.
Meanwhile, the docs have this to say: docs.python.org/2/faq/design.html#...
And the follow-up might have some more info: docs.python.org/2/faq/design.html#...
Here's a stackOverflow answer that, if not fully answering your question, will probably at least give you enough leads to get the answers you're looking for: stackoverflow.com/a/9022835/26196
👆🏽👆🏽👆🏽 That SO post actually links to Python source code, which is obviously the "one true" answer about it's implementation, if you are so inclined do dig in in such a way =)
Probably youtube.com/watch?v=npw4s1QTmPg is the video you seek.
And PLEASE: refer to pythonclock.org. Does it make sense to refer to the documentation of a language that will become unsupported in 42 days? (And, more to the point, has an outdated implementation of dictionaries.)
Thanks for pointing that out. I'm well aware of Python2's EOL. I think providing a few good leads for someone looking for answers was a kind thing to do.
I doubt Python2's implementation is dangerous to the extent that it's harmful to share what I did. Please be careful to build on other's answers, instead of discouraging folks from trying to drop a few leads.
I acknowledge that if I had directly provided links to source, it would have been better that they were more up-to-date sources. I wasn't in a position to do that, so gave what I had.
That's not the specific video, but it's probably a better example than the one I remember. So thanks for pointing that one out! ;)
It is much better to provide links and things to Python 3.x resources, for sure!
Not dangerous, just useless (in the context). I can't see how changing 2 to 3 in that url could be perceived as so hard to do.
Good call Tommy. Aside from those resources (and their Python 3 versions), I found this post very helpful: laurentluce.com/posts/python-dicti...