Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/modules/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,20 @@ def sort(self, pfmris=None, pubs=None):
If neither 'pfmris' or 'pubs' is provided, all entries will be
sorted."""

# Version objects are expensive to construct and the same
# version string commonly recurs across many stems (packages
# built and published together share branch and timestamp), so
# construct each distinct version only once per sort.
vcache = {}

def key_func(item):
return pkg.version.Version(item["version"])
ver = item["version"]
try:
return vcache[ver]
except KeyError:
v = pkg.version.Version(ver)
vcache[ver] = v
return v

self.load()
if pfmris is not None:
Expand Down
Loading