Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o, Matt Turner <mattst88@g.o>
Cc: "Wolfgang E. Sanyer" <WolfgangESanyer@×××××.com>
Subject: Re: [gentoo-portage-dev] [PATCH 4/4] portage.eapi: use functools @lru_cache decorator instead of custom implementation
Date: Sat, 26 Feb 2022 22:26:25
Message-Id: 87ab760d-a8e7-c218-01ac-71f70a43b5ec@gentoo.org
In Reply to: Re: [gentoo-portage-dev] [PATCH 4/4] portage.eapi: use functools @lru_cache decorator instead of custom implementation by Zac Medico
1 On 2/26/22 10:04, Zac Medico wrote:
2 > On 2/23/22 20:14, Matt Turner wrote:
3 >> From: "Wolfgang E. Sanyer" <WolfgangESanyer@×××××.com>
4 >>
5 >> Reviewed-by: Matt Turner <mattst88@g.o>
6 >> Signed-off-by: Wolfgang E. Sanyer <WolfgangESanyer@×××××.com>
7 >> ---
8 >>   lib/portage/eapi.py | 155 ++++++++++++++++++++------------------------
9 >>   1 file changed, 72 insertions(+), 83 deletions(-)
10 >>
11 >> diff --git a/lib/portage/eapi.py b/lib/portage/eapi.py
12 >> index 56e64620a..efcc6c2a0 100644
13 >> --- a/lib/portage/eapi.py
14 >> +++ b/lib/portage/eapi.py
15 >> @@ -2,12 +2,10 @@
16 >>   # Distributed under the terms of the GNU General Public License v2
17 >>   import collections
18 >> -import operator
19 >> -import types
20 >> -
21 >> -from portage import eapi_is_supported
22 >> +from functools import lru_cache
23 >> +@lru_cache(None)
24 >>   def eapi_has_iuse_defaults(eapi):
25 >>       if eapi is None:
26 >>           return True
27 >> @@ -15,6 +13,7 @@ def eapi_has_iuse_defaults(eapi):
28 >>       return eapi != "0"
29 >
30 > I think this patch misses the point of the original caching mechanism.
31 > It doesn't make sense to cache results of the individual eapi_*
32 > functions if they no longer contribute to the _eapi_attrs cache.
33
34 To clarify, the only reason that the eapi_* functions were cached was so
35 that they would trigger population of the _eapi_attrs cache. In the
36 absence of this_eapi_attrs cache population feature, I doubt that it's
37 very useful to put the lru_cache on the indivdual eapi_* functions.
38 --
39 Thanks,
40 Zac

Attachments

File name MIME type
OpenPGP_signature.asc application/pgp-signature