[poll] anyone else needs fast random element access off a dictionary?
fuf at mageo.cz
Tue Feb 11 18:47:00 CET 2003
there's nothing wrong with this approach of course. the only problem is
that maintaing lists of keys, values or even items would be very
expensive in case the keys would change very often.
Peter Hansen wrote:
>What is wrong with subclassing to create your own object, with
>the property of maintaining a list of the keys, or values, or both,
>and even a getRandomItem() method which does the above in a very
>That's what object-oriented programming is all about... in this
>case it lets you optimize for the frequent case, even though it
>might slow down other situations in a fairly minor way.
fuf (fuf at mageo.cz)
More information about the Python-list