Re: [PATCH v2] perf scripts python: Add Python 3 support to netdev-times.py

From: Tony Jones
Date: Fri Jan 18 2019 - 20:21:44 EST


On 1/17/19 1:45 AM, Seeteena Thoufeek wrote:> Support both Python 2 and Python 3 in netdev-times.py. ``print``
> is now a function rather than a statement. This should have no
> functional change.

Same feedback as all the other patches applies.

In addition:

$ git annotate tools/perf/scripts/python/netdev-times.py | grep "all_event_list.sort"
359d5106a2ff4 (Koki Sanagi 2010-08-23 18:47:09 +0900 175) all_event_list.sort(lambda a,b :cmp(a[EINFO_IDX_TIME],

I didn't think the above was valid with Python3.

In my version (https://build.opensuse.org/package/view_file/devel:tools/perf/port-failed-syscalls-by-pid-script-to-python3.patch?expand=1)
I reworked it as:

from functools import cmp_to_key
all_event_list.sort(key=cmp_to_key(lambda a,b :a[EINFO_IDX_TIME] < b[EINFO_IDX_TIME]))

Tony