[Piuparts-devel] get_files_owned_by_packages

Herbert Fortes terberh at gmail.com
Wed May 15 00:36:32 BST 2019


Hi,

I did a refactor to get_files_owned_by_packages[0]. I did
5 versions.

[0] - https://salsa.debian.org/debian/piuparts/blob/develop/piuparts.py#L1661

The best version for the programmer is the one with
pathlib and dict.setdefault:

vdir = Path("var/lib/dpkg/info")
vdict = {}

for basename in vdir.glob("*.list"):
    for line in basename.read_text().split("\n"):
        vdict.setdefault(line.strip(), []).append(basename.stem)
        
del vdict['']
return vdict

But it costs a lot.

orig:     30.34737383400352 segundos (100 loops).
path_obj: 73.14698908800347 segundos (100 loops).

To a pkg maintainer it is not a big problem, tough.

That would be worth?



Regards,
Herbert



More information about the Piuparts-devel mailing list