[Yum-devel] [PATCH] make sure when we return items we sort the counts of things matched from the tagsdb into the rest of the matches. FIXME added to get rid of the silly sorting list as it appears to only want to make me cry
Seth Vidal
skvidal at fedoraproject.org
Fri Mar 12 14:28:24 UTC 2010
On Fri, 12 Mar 2010, Seth Vidal wrote:
>
>
> On Fri, 12 Mar 2010, Tim Lauridsen wrote:
>
>>
>> Agree, results_by_pkg.setdefault(pkg, []).append((matchkeys, tagresults))
>> look reelly creapy :)
>> I cut down a number of lines, but it don't look nice. but both way are OK
>> for me, but it make my eyes bleed
>> :)
>>
>
> So here's my question: Does results_by_pkg.setdefault(......) actually run
> more quickly than the if statement?
interesting:
http://fpaste.org/aOLJ/raw/
this script measures 3 mechanism for making a dict like we're describing.
run it yourself - but dict3 is using:
if not item in dict:
dict[item] = []
dict1 is one setdefault
dict2 is a pretty bizarre setdefault
long story short - dict3 is twice as fast as dict1 and a bazillion times
faster than dict2.
so I'll stick w/o the setdefaults() and maybe go see if there are more
places we do this.
it's nice when that which is easier to read is also faster.
-sv
More information about the Yum-devel
mailing list