File tree 2 files changed +10
-10
lines changed
2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,12 @@ Unreleased
28
28
extreme case of combining 700+ data files, the time dropped from more than
29
29
three hours to seven minutes. Thanks for Kraken Tech for funding the fix.
30
30
31
+ - Performance improvements for generating HTML reports, with a side benefit of
32
+ reducing memory use, closing `issue 1791 `_. Thanks to Daniel Diniz for
33
+ helping to diagnose the problem.
34
+
35
+ .. _issue 1791 : https://github.com/nedbat/coveragepy/issues/1791
36
+
31
37
32
38
.. scriv-start-here
33
39
Original file line number Diff line number Diff line change 6
6
from __future__ import annotations
7
7
8
8
import ast
9
- import functools
10
9
import io
11
10
import keyword
12
11
import re
@@ -163,20 +162,15 @@ def source_token_lines(source: str) -> TSourceTokenLines:
163
162
yield line
164
163
165
164
166
- @functools .lru_cache (maxsize = 100 )
167
165
def generate_tokens (text : str ) -> TokenInfos :
168
- """A cached version of `tokenize.generate_tokens`.
166
+ """A helper around `tokenize.generate_tokens`.
169
167
170
- When reporting, coverage.py tokenizes files twice, once to find the
171
- structure of the file, and once to syntax-color it. Tokenizing is
172
- expensive, and easily cached.
168
+ Originally this was used to cache the results, but it didn't seem to make
169
+ reporting go faster, and caused issues with using too much memory.
173
170
174
- Unfortunately, the HTML report code tokenizes all the files the first time
175
- before then tokenizing them a second time, so we cache many. Ideally we'd
176
- rearrange the code to tokenize each file twice before moving onto the next.
177
171
"""
178
172
readline = io .StringIO (text ).readline
179
- return list ( tokenize .generate_tokens (readline ) )
173
+ return tokenize .generate_tokens (readline )
180
174
181
175
182
176
def source_encoding (source : bytes ) -> str :
You can’t perform that action at this time.
0 commit comments