1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-09-23 12:21:54 +01:00

target: Open the possiblity for optimizing multi-source push/pulls

This commit is contained in:
Douglas Raillard
2021-08-12 15:25:58 +01:00
committed by Marc Bonnici
parent 173df18f29
commit 477e82c444
2 changed files with 36 additions and 16 deletions

View File

@@ -971,3 +971,16 @@ class InitCheckpoint(metaclass=InitCheckpointMeta):
Inherit from this class to set the :class:`InitCheckpointMeta` metaclass.
"""
pass
def groupby_value(dct):
"""
Process the input dict such that all keys sharing the same values are
grouped in a tuple, used as key in the returned dict.
"""
key = itemgetter(1)
items = sorted(dct.items(), key=key)
return {
tuple(map(itemgetter(0), _items)): v
for v, _items in groupby(items, key=key)
}