[Piuparts-devel] piuparts.py and piuparts-analyze.py

Herbert Fortes terberh at gmail.com
Sat Mar 23 17:30:32 GMT 2019


Hi,

One patch for piuparts.py

.lstrip instead of an if with two returns:

    def relative(self, pathname):
-        if pathname.startswith('/'):
-            return os.path.join(self.name, pathname[1:])
-        return os.path.join(self.name, pathname)
+        return os.path.join(self.name, pathname.lstrip('/'))

https://github.com/hpfn-d/piuparts_3/commit/67abfe28b3c32b9aca02e65d96a280782efa3ec8



One patch for piuparts-analize.py

.endswith and list comprehensions instead of a for-loop with .append

- versions = []
- for found_version in found_versions:
-     v = found_version.rsplit('/', 1)[-1]
-     if v == "None":
-         # ignore $DISTRO/None versions
-         pass
-     else:
-         versions.append(v)
+
+    versions = [found_version.rsplit('/', 1)[-1]
+                for found_version in found_versions
+                if not found_version.endswith("None")]

https://github.com/hpfn-d/piuparts_3/pull/28

list comprehensions are more readable and
often faster.



Regards,
Herbert

an 'import dis' here:
https://stackoverflow.com/questions/30245397/why-is-a-list-comprehension-so-much-faster-than-appending-to-a-list



More information about the Piuparts-devel mailing list