Are dictionaries the same as hashtables?

Diez B. Roggisch deets at nospam.web.de
Tue Aug 26 18:15:33 CEST 2008


Cameron Laird wrote:

> In article <6hi153Fliuu4U1 at mid.uni-berlin.de>,
> Diez B. Roggisch <deets at nospam.web.de> wrote:
>>Martin Marcher wrote:
>>
>>> On 2008-08-26 00:32:20, cnb wrote:
>>>> Are dictionaries the same as hashtables?
> .
> .
> .
>>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
> 
> ?  I'm lost.  As I understand your terms, Python's dictionaries
> map keys to objects, but you would prefer that Python's
> dictionaries map keys only to lists of values.  That *sounds*
> like a complexification, at best.  Are you trying to make a
> point about implementation aligning with semantics?

The OP seems to want that (or at least sees it as one of two viable design
choices), see his other answer in this thread.

I certainly *don't* agree with that, I merely pointed out that python comes
with means to easily create such a data-structure in the case it is needed.

Diez



More information about the Python-list mailing list