From b31a0ce6d0091312283293a8c2e6101730c52341 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Tue, 10 Mar 2020 17:50:44 +0000 Subject: [PATCH] tracemalloc: rm filename editing from 'pretty top' I've used this recipe a couple times and the filename editing has always been less than useful and something I've removed. This is because many modules end up losing which package they are located in, e.g. `util/date.py`. --- Doc/library/tracemalloc.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Doc/library/tracemalloc.rst b/Doc/library/tracemalloc.rst index e423470036558f..3eee9457fb29a8 100644 --- a/Doc/library/tracemalloc.rst +++ b/Doc/library/tracemalloc.rst @@ -202,10 +202,8 @@ 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" - 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)