Maric Michaud <[EMAIL PROTECTED]> writes:
> Le Friday 13 June 2008 17:55:44 Karsten Heymann, vous avez écrit :
>> Maric Michaud <[EMAIL PROTECTED]> writes:
>> > So, writing C in python, which has dictionnary as builtin type,
>> > should be considered "more elegant" ?
>>
>> IMO that's a bit harsh.

> harsh ? Sorry, I'm not sure to understand.

Never mind, I got carried away.

>> I'd never argue that using a dictionary is the obvious and natural
>> data structure for this case. But is it the best? Honestly, as your
>> very nice example shows, we have two solutions that are equally
>> fast, equally complex to code and equally robust, but one needs
>
> Yes, but my example take ordered integer for keys (users' names)
> which they should not be in a real case, so retrieving the result is
> by way easier (and faster) with a dictionnary.

Of course. As I wrote in my first post, my proposal dependeds upon the
users being a numerical and compact list with a known maximum, as in
the OP's example. Otherwise my approach makes no sense at all :-)

>> approximately the double amount of memory compared to the other.
>
> I don't see how you came to this conclusion. Are you sure the extra
> list take twice more memory than the extra dictionary ?

I'm referring to the resulting data structure. A list with n items
should take approx. half the space of a dictionary with n keys and n
entries. Or, the other way round, if i have a dictionary with keys
1..n, why shouldn't I use a list instead.

Yours,
Karsten
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to