Paul Rubin wrote:

>>      items = d.items()
>>      items.sort(key=operator.itemgetter(1), reverse=True)
>>
>> the items list would require a couple of megabytes for 150k dictionary
>> entries, or so.  the key map needs some memory too, but the rest of
>> the sort is done in place.
> 
> I think the OP's method avoided the key map.

right. I should have written "most efficient", not memory efficient. 
the items+itemgetter approach is a bit faster, but uses a few extra 
megabytes of memory temporarily, during the sort.

</F>

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to