From 6a0378b3b481a081e5f3528f9ca4d3be768e675f Mon Sep 17 00:00:00 2001 From: Eduard Anghel Date: Mon, 2 Mar 2020 14:33:16 +0000 Subject: [PATCH 1/2] Pretty top - use non-stripped version of filename when printing --- Doc/library/tracemalloc.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Doc/library/tracemalloc.rst b/Doc/library/tracemalloc.rst index e423470036558fe..8d653b5a6a75455 100644 --- a/Doc/library/tracemalloc.rst +++ b/Doc/library/tracemalloc.rst @@ -203,9 +203,8 @@ ignoring ```` and ```` files:: for index, stat in enumerate(top_stats[:limit], 1): frame = stat.traceback[0] # replace "/path/to/module/file.py" with "module/file.py" - filename = os.sep.join(frame.filename.split(os.sep)[-2:]) print("#%s: %s:%s: %.1f KiB" - % (index, filename, frame.lineno, stat.size / 1024)) + % (index, frame.filename, frame.lineno, stat.size / 1024)) line = linecache.getline(frame.filename, frame.lineno).strip() if line: print(' %s' % line) From 8bbe66226c0ec412d9049ea2626e73293e5795d9 Mon Sep 17 00:00:00 2001 From: Eduard Anghel Date: Mon, 2 Mar 2020 14:42:39 +0000 Subject: [PATCH 2/2] Remove comment relating to previous commit. --- Doc/library/tracemalloc.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/Doc/library/tracemalloc.rst b/Doc/library/tracemalloc.rst index 8d653b5a6a75455..3eee9457fb29a8d 100644 --- a/Doc/library/tracemalloc.rst +++ b/Doc/library/tracemalloc.rst @@ -202,7 +202,6 @@ ignoring ```` and ```` files:: print("Top %s lines" % limit) for index, stat in enumerate(top_stats[:limit], 1): frame = stat.traceback[0] - # replace "/path/to/module/file.py" with "module/file.py" print("#%s: %s:%s: %.1f KiB" % (index, frame.filename, frame.lineno, stat.size / 1024)) line = linecache.getline(frame.filename, frame.lineno).strip()