[Python-Dev] 2.4a2, and @decorators

Gareth McCaughan gmccaughan at synaptics-uk.com
Fri Aug 6 14:00:44 CEST 2004


On Friday 2004-08-06 12:42, Michael Hudson wrote:

>>>>>> class C(random.choice([dict, list])):
>>>>>>     pass
>>>>>>
>>>>>> is my favourite example of this :-)
>>>>>
>>>>> Where is THAT monstrocity used!?
>>>>
>>>> Well, it's not, I hope :-)
>>>
>>> Hmmm... maybe if you had some algorithm that was more efficient
>>> using either a list or a dict, depending on the input data, but
>>> in a way that makes it difficult to tell ahead of time which
>>> to use, and you want to improve the average behaviour...
>>
>> ... then you'd do better to find which out of (dict,list)
>> does better on average, and always use that one. Sorry. :-)
>
> By running the above code on a wide range of inputs? :-)

<boring>No, you'd get more reliable results for a given expenditure
of effort by running half as many input datasets with class C(dict)
and class C(list).</boring>

-- 
g




More information about the Python-Dev mailing list