Are dictionaries the same as hashtables?

Martin martin at marcher.name
Tue Aug 26 10:50:26 EDT 2008


On Tue, Aug 26, 2008 at 9:52 AM, cnb <circularfunc at yahoo.se> wrote:
> On Aug 26, 9:43 am, Martin Marcher <mar... at marcher.name> 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.
>>
>> PS: your sig was *a bit* longer than you question. please don't do
>> that...
>>
>>  signature.asc
>> < 1KViewDownload
>
> my what?

Hehe,

it was *my* sig... i was using some old box with a mut config that
still had the fortune script in it... sorry.

Anyway what I meant by collision handling was:

$ python
Python 2.5.2 (r252:60911, Jul 31 2008, 17:31:22)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> l = {}
>>> l
{}
>>> l["a"] = 12
>>> l["b"] = 13
>>> l
{'a': 12, 'b': 13}
>>> l["a"] = "This is a collision"
>>> l
{'a': 'This is a collision', 'b': 13}
>>>

As you see position "a" is simply overwritten. Probably "sane" doesn't
really apply because how could the python creators possibly know
whether I just want to overwrite the value or indeed want some form of
collision handling (talk about lists vs. trees with there
subforms...)...

If one would want that he/she/it could still subclass dict and do more magic.

/martin

-- 
http://www.xing.com/profile/Martin_Marcher

You are not free to read this message,
by doing so, you have violated my licence
and are required to urinate publicly. Thank you.



More information about the Python-list mailing list