aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Raplee <kenrap@kennethraplee.com>2022-03-22 00:32:42 -0700
committerSam James <sam@gentoo.org>2022-03-28 00:06:39 +0100
commit7c8d5742d76d65ff3eb203ff269f65817b8b87fc (patch)
tree99f59544e94cb2c87589693ac247c6a2549d41c1
parentPrefer generator expressions over list comprehensions (diff)
downloadportage-7c8d5742.tar.gz
portage-7c8d5742.tar.bz2
portage-7c8d5742.zip
Prefer tuples over explicit lists
Tuples offer better memory usage compared to lists due to Python's ability to optimize with immutability. While these small amount of changes won't shave off much, the plan is to find more of these which will arithmetically have significance to the codebase. Signed-off-by: Kenneth Raplee <kenrap@kennethraplee.com> Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r--lib/portage/const.py10
-rw-r--r--lib/portage/data.py4
-rw-r--r--lib/portage/glsa.py8
3 files changed, 11 insertions, 11 deletions
diff --git a/lib/portage/const.py b/lib/portage/const.py
index 98eb7e4f2..f0f57067a 100644
--- a/lib/portage/const.py
+++ b/lib/portage/const.py
@@ -125,7 +125,7 @@ EBUILD_PHASES = (
"other",
)
SUPPORTED_FEATURES = frozenset(
- [
+ (
"assume-digests",
"binpkg-docompress",
"binpkg-dostrip",
@@ -217,14 +217,14 @@ SUPPORTED_FEATURES = frozenset(
"usersync",
"webrsync-gpg",
"xattr",
- ]
+ )
)
EAPI = 8
HASHING_BLOCKSIZE = 32768
-MANIFEST2_HASH_DEFAULTS = frozenset(["BLAKE2B", "SHA512"])
+MANIFEST2_HASH_DEFAULTS = frozenset(("BLAKE2B", "SHA512"))
MANIFEST2_HASH_DEFAULT = "BLAKE2B"
MANIFEST2_IDENTIFIERS = ("AUX", "MISC", "DIST", "EBUILD")
@@ -248,7 +248,7 @@ VCS_DIRS = ("CVS", "RCS", "SCCS", ".bzr", ".git", ".hg", ".svn")
# List of known live eclasses. Keep it in sync with cnf/sets/portage.conf
LIVE_ECLASSES = frozenset(
- [
+ (
"bzr",
"cvs",
"darcs",
@@ -257,7 +257,7 @@ LIVE_ECLASSES = frozenset(
"golang-vcs",
"mercurial",
"subversion",
- ]
+ )
)
SUPPORTED_BINPKG_FORMATS = ("tar", "rpm")
diff --git a/lib/portage/data.py b/lib/portage/data.py
index 8c58ad0fc..de7d88e5e 100644
--- a/lib/portage/data.py
+++ b/lib/portage/data.py
@@ -83,12 +83,12 @@ def _target_root():
def portage_group_warning():
warn_prefix = colorize("BAD", "*** WARNING *** ")
- mylines = [
+ mylines = (
"For security reasons, only system administrators should be",
"allowed in the portage group. Untrusted users or processes",
"can potentially exploit the portage group for attacks such as",
"local privilege escalation.",
- ]
+ )
for x in mylines:
writemsg(warn_prefix, noiselevel=-1)
writemsg(x, noiselevel=-1)
diff --git a/lib/portage/glsa.py b/lib/portage/glsa.py
index 4b92d52e0..1b68bc0e9 100644
--- a/lib/portage/glsa.py
+++ b/lib/portage/glsa.py
@@ -152,7 +152,7 @@ def getListElements(listnode):
@rtype: List of Strings
@return: a list that contains the value of the <li> elements
"""
- if not listnode.nodeName in ["ul", "ol"]:
+ if not listnode.nodeName in ("ul", "ol"):
raise GlsaFormatException("Invalid function call: listnode is not <ul> or <ol>")
rValue = [
getText(li, format="strip")
@@ -191,8 +191,8 @@ def getText(node, format, textfd=None): # pylint: disable=redefined-builtin
returnNone = False
else:
returnNone = True
- if format in ["strip", "keep"]:
- if node.nodeName in ["uri", "mail"]:
+ if format in ("strip", "keep"):
+ if node.nodeName in ("uri", "mail"):
textfd.write(f"{node.childNodes[0].data}:{node.getAttribute('link')}")
else:
for subnode in node.childNodes:
@@ -206,7 +206,7 @@ def getText(node, format, textfd=None): # pylint: disable=redefined-builtin
for p_subnode in subnode.childNodes:
if p_subnode.nodeName == "#text":
textfd.write(p_subnode.data.strip())
- elif p_subnode.nodeName in ["uri", "mail"]:
+ elif p_subnode.nodeName in ("uri", "mail"):
textfd.write(p_subnode.childNodes[0].data)
textfd.write(" ( " + p_subnode.getAttribute("link") + " )")
textfd.write(NEWLINE_ESCAPE)