Commit c465a242 authored by Rafael Fonseca's avatar Rafael Fonseca

fixes #962 - fix lambda on both py2 and py3

See: https://www.python.org/dev/peps/pep-3113/
parent 5467ccf4
...@@ -147,13 +147,13 @@ while True: ...@@ -147,13 +147,13 @@ while True:
print() print()
data = bpf["allocs"] data = bpf["allocs"]
if args.top_count: if args.top_count:
data = sorted(data.items(), key=lambda k, v: v.num_allocs) data = sorted(data.items(), key=lambda kv: kv[1].num_allocs)
data = data[-args.top_count:] data = data[-args.top_count:]
elif args.top_size: elif args.top_size:
data = sorted(data.items(), key=lambda k, v: v.total_size) data = sorted(data.items(), key=lambda kv: kv[1].total_size)
data = data[-args.top_size:] data = data[-args.top_size:]
else: else:
data = sorted(data.items(), key=lambda k, v: v.total_size) data = sorted(data.items(), key=lambda kv: kv[1].total_size)
print("%-30s %8s %12s" % ("TYPE", "# ALLOCS", "# BYTES")) print("%-30s %8s %12s" % ("TYPE", "# ALLOCS", "# BYTES"))
for key, value in data: for key, value in data:
if args.language == "c": if args.language == "c":
......
...@@ -239,10 +239,10 @@ class Tool(object): ...@@ -239,10 +239,10 @@ class Tool(object):
counts.update(probe.get_counts(self.bpf)) counts.update(probe.get_counts(self.bpf))
targets.update(probe.targets) targets.update(probe.targets)
if self.args.sort: if self.args.sort:
counts = sorted(counts.items(), key=lambda _, v: counts = sorted(counts.items(), key=lambda kv:
-v.get(self.args.sort.upper(), 0)) -kv[1].get(self.args.sort.upper(), 0))
else: else:
counts = sorted(counts.items(), key=lambda k, _: k) counts = sorted(counts.items(), key=lambda kv: kv[0])
for pid, stats in counts: for pid, stats in counts:
print("%-6d %-20s %-10d %-6d %-10d %-8d %-6d %-6d" % ( print("%-6d %-20s %-10d %-6d %-10d %-8d %-6d %-6d" % (
pid, targets[pid][:20], pid, targets[pid][:20],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment