Re: How does a dictionary work exactly?

2015-07-17 Thread Ned Batchelder
On Thursday, July 16, 2015 at 2:59:02 PM UTC-4, Skip Montanaro wrote: On Thu, Jul 16, 2015 at 1:36 PM, yoursurrogate...@gmail.com yoursurrogate...@gmail.com wrote: If I understand correctly, lookup would not be a constant, yes? On the contrary, that's what you desire, nearly constant time

Re: How does a dictionary work exactly?

2015-07-17 Thread Skip Montanaro
On Fri, Jul 17, 2015 at 9:32 AM, Ned Batchelder n...@nedbatchelder.com wrote: Maybe people are reading a different implementation than I am. Python's dict object doesn't use linked lists to deal with hash collisions, it probes other slots instead. No, I was working a) from memory, and b) not

How does a dictionary work exactly?

2015-07-16 Thread yoursurrogate...@gmail.com
Hello, I was trying to see how some have implemented a hashtable. I took a gather at dictobject.h/.c. It seems that underneath it all it's a linked list and that is used in order to store the actual information (I'm looking at PyDictEntry.) Am I correct in my assumption or is there more to

Re: How does a dictionary work exactly?

2015-07-16 Thread Skip Montanaro
I was trying to see how some have implemented a hashtable. I took a gather at dictobject.h/.c. It seems that underneath it all it's a linked list and that is used in order to store the actual information (I'm looking at PyDictEntry.) Am I correct in my assumption or is there more to

Re: How does a dictionary work exactly?

2015-07-16 Thread Skip Montanaro
On Thu, Jul 16, 2015 at 1:36 PM, yoursurrogate...@gmail.com yoursurrogate...@gmail.com wrote: If I understand correctly, lookup would not be a constant, yes? On the contrary, that's what you desire, nearly constant time execution. To the greatest extent possible, you want the linked lists to be