diff options
author | Carl Friedrich Bolz-Tereick <cfbolz@gmx.de> | 2022-05-28 21:34:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-28 12:34:43 -0700 |
commit | 08ec70fe8acbd5864b3c8c3dcc4c65c38afeeff8 (patch) | |
tree | 54fe62d6fb4abb3b388dca2b0fd1edcf31fb31cd /coverage/pytracer.py | |
parent | 1087f173f877c66872b0d993feb0860560def466 (diff) | |
download | python-coveragepy-git-08ec70fe8acbd5864b3c8c3dcc4c65c38afeeff8.tar.gz |
perf: speed up python tracer with frame.f_trace_lines = False (#1381)
use the python >= 3.7 feature of being able to disable line tracing by
setting the frame attribute f_trace_lines to False. This can be used for
the frames of functions that we aren't collecting coverage information
for (eg those functions in the stdlib).
This speeds up the pure python tracer in CPython by ~9x and in PyPy by
80% on a coverage run of one realistic project that I tried.
Diffstat (limited to 'coverage/pytracer.py')
-rw-r--r-- | coverage/pytracer.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/coverage/pytracer.py b/coverage/pytracer.py index f0319491..1f0f7924 100644 --- a/coverage/pytracer.py +++ b/coverage/pytracer.py @@ -159,6 +159,8 @@ class PyTracer: if tracename not in self.data: self.data[tracename] = set() self.cur_file_data = self.data[tracename] + else: + frame.f_trace_lines = False # The call event is really a "start frame" event, and happens for # function calls and re-entering generators. The f_lasti field is # -1 for calls, and a real offset for generators. Use <0 as the |