[Tutor] Dictionaries
Daniel Yoo
dyoo@hkn.EECS.Berkeley.EDU
Thu, 10 Feb 2000 14:08:36 -0800 (PST)
> Message: 3
> From: rhicks@rma.edu
> To: tutor@python.org
> Date: Wed, 9 Feb 100 13:10:17 +0000
> Subject: [Tutor] Dictionaries...
>
> On page 50 of "Learning Python" is makes the statement that dictionaries in
> Python are randomized in their order in order to provide quick lookup. I have
> talked to a programmer buddy and he doesn't know why this is. Why does an
> unordered list provide a quick lookup?
When they say unordered, they don't mean that the list has no pattern.
What they refer to is the function that, given a key, figures out where a
value is in the list. What we need is a nice function that evenly
distributes the keys through the list, and it's this that makes the list
look "unordered".
Getting a list of keys off this table will give us an "unordered" list.
The randomized part refers to the way the categories are chosen. It's not
quite alphabetic; it does some extra stuff to make sure that the buckets
have the same distribution of elements. So that's why the list's
unordered.