[Python-checkins] tracemalloc: 'pretty top' example no longer changes the filename (GH-18903)
Adam Johnson
webhook-mailer at python.org
Tue Mar 10 14:18:59 EDT 2020
https://github.com/python/cpython/commit/d06eec218eac81225f9017951cddfc211fed9325
commit: d06eec218eac81225f9017951cddfc211fed9325
branch: master
author: Adam Johnson <me at adamj.eu>
committer: GitHub <noreply at github.com>
date: 2020年03月10日T19:18:50+01:00
summary:
tracemalloc: 'pretty top' example no longer changes the filename (GH-18903)
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`.
files:
M Doc/library/tracemalloc.rst
diff --git a/Doc/library/tracemalloc.rst b/Doc/library/tracemalloc.rst
index e423470036558..3eee9457fb29a 100644
--- a/Doc/library/tracemalloc.rst
+++ b/Doc/library/tracemalloc.rst
@@ -202,10 +202,8 @@ ignoring ``<frozen importlib._bootstrap>`` and ``<unknown>`` 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)
More information about the Python-checkins
mailing list