[Yum-devel] [PATCH] Call repo.__hash__() less.
ville.skytta at iki.fi
Fri Jan 29 07:25:00 UTC 2010
On Friday 29 January 2010, James Antill wrote:
> On Thu, 2010-01-28 at 23:48 +0200, Ville Skyttä wrote:
> > On my (typicalish) Fedora 11 box, brings down number of those calls in
> > a check-update run from ~146k to ~27k and speeds it up by ~7%.
> What about just changing Repository.__hash__ to something like:
> def __hash__(self):
> if self.__cached_hash is None:
> self.__cached_hash = hash(self.id)
> return self.__cached_hash
> ...with the obvious "self.__cached_hash = None" in __init__?
I tried that already before coming up with the submitted patch but it didn't
end up speeding up my check-update test case, in fact IIRC it made it slightly
(There's also the theoretical problem with the above simple approach that if a
repo's id changes, the hash wouldn't, but changing a repo's id on the fly is
probably a no no anyway. Easy to fix but caching the hash doesn't seem worth
it anyway so meh.)
More information about the Yum-devel