Martin Marcher wrote:

> On 2008-08-26 00:32:20, cnb wrote:
>> Are dictionaries the same as hashtables?
> 
> Yes, but there is nothing in there that does sane collision handling
> like making a list instead of simply overwriting.

The term "collision" is rather well defined when talking about associative
arrays using hashing (which python's dicts are): it means that two distinct
keys produce the same hash-value, leading to a bucket collision. And of
course python deals with that sanely, and creates a list of objects inside
the bucket which is traversed and comparison is used to determine which
actual value to retrieve.

Python does not have a "one key maps to a list of values"-semantics - which
I consider the sane choice...

However, you can have that using the defaultdict for example:

listdict = defaultdict(list)

listdict[key].append(value)

Diez
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to