[Yum-devel] [PATCH] Minor opt. for allowedMultipleInstalls() and pkg.*_names callers

Seth Vidal skvidal at fedoraproject.org
Thu Oct 29 04:39:48 UTC 2009



On Wed, 28 Oct 2009, James Antill wrote:


> ---
> yum/depsolve.py |   11 ++++++-----
> yum/packages.py |    9 ++++-----
> 2 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/yum/depsolve.py b/yum/depsolve.py
> index e5b3a42..4d3d5ca 100644
> --- a/yum/depsolve.py
> +++ b/yum/depsolve.py
> @@ -188,13 +188,14 @@ class Depsolve(object):
>         """takes a packageObject, returns 1 or 0 depending on if the package
>            should/can be installed multiple times with different vers
>            like kernels and kernel modules, for example"""
> -
> -        if po.name in self.conf.installonlypkgs:
> +
> +        iopkgs = set(self.conf.installonlypkgs)
> +        if po.name in iopkgs:
>             return True
>
> -        provides = po.provides_names
> -        if filter (lambda prov: prov in self.conf.installonlypkgs, provides):
> -            return True
> +        for prov in po.provides_names:
> +            if prov in iopkgs:
> +                return True
>
>         return False
>
> diff --git a/yum/packages.py b/yum/packages.py
> index 71430fd..709e73e 100644
> --- a/yum/packages.py
> +++ b/yum/packages.py
> @@ -454,11 +454,10 @@ class RpmBase(object):
>         return self.files.keys()
>
>     def returnPrcoNames(self, prcotype):
> -        results = []
> -        lists = self.returnPrco(prcotype)
> -        for (name, flag, vertup) in lists:
> -            results.append(name)
> -        return results
> +        if not hasattr(self, '_cache_prco_names_' + prcotype):
> +            data = [n for (n, f, v) in self.returnPrco(prcotype)]
> +            setattr(self, '_cache_prco_names_' + prcotype, data)
> +        return getattr(self, '_cache_prco_names_' + prcotype)
>
>     def getProvidesNames(self):
>         warnings.warn('getProvidesNames() will go away in a future version of Yum.\n',

Just out of curiosity - how minor of an opt is this?

As in - is it even detectable and do we take a memory hit for caching this 
data?

-sv



More information about the Yum-devel mailing list