lkml.org 
[lkml]   [2019]   [Jan]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2] perf scripts python: Add Python 3 support to netdev-times.py
From
Date
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

\
 
 \ /
  Last update: 2019-01-19 02:22    [W:0.148 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site