Skip to content

Instantly share code, notes, and snippets.

@saswata-dutta
Created June 17, 2021 08:25
Show Gist options
  • Save saswata-dutta/7d64d720b46b752d99f98b166ccc9cdd to your computer and use it in GitHub Desktop.
Save saswata-dutta/7d64d720b46b752d99f98b166ccc9cdd to your computer and use it in GitHub Desktop.
operate on two list at once
def process(kstr, vstr, n):
k = filter(lambda x: x != "id", kstr.split())
v = vstr.split()
kv = list(zip(k, v))
exe = filter(lambda x: x[0] == "execution", kv)
tot = filter(lambda x: x[0] == "total", kv)
times = ((float(t[1]), float(e[1])) for e,t in zip(exe, tot))
best_times = sorted(times)[:n]
return best_times
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment