No trees in the stdlib?

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Fri Jul 3 10:08:20 CEST 2009


In message <mailman.2446.1246491262.8015.python-list at python.org>, João 
Valverde wrote:

> Lawrence D'Oliveiro wrote:
>
>> In message <mailman.2140.1245996088.8015.python-list at python.org>, João
>> Valverde wrote:
>>   
>>> Simple example usage case: Insert string into data structure in sorted
>>> order if it doesn't exist, else retrieve it.
>>
>>     the_set = set( ... )
>>
>>     if str in the_set :
>>         ... "retrieval" case ...
>>     else :
>>         the_set.add(str)
>>     #end if
>>
>> Want sorted order?
>>
>>     sorted(tuple(the_set))
>>
>> What could be simpler?
> 
> Try putting that inside a loop with thousands of iterations and you'll
> see what the problem is.

You could apply the same argument to anything. E.g. why create a tree 
structure with a million elements? Try putting that inside a loop with 
thousands of iterations and you'll see what the problem is.




More information about the Python-list mailing list