diff options
-rw-r--r-- | AUTHORS.txt | 1 | ||||
-rw-r--r-- | CHANGES.txt | 3 | ||||
-rw-r--r-- | coverage/collector.py | 16 |
3 files changed, 19 insertions, 1 deletions
diff --git a/AUTHORS.txt b/AUTHORS.txt index 1de7e9f6..5d40edee 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -17,6 +17,7 @@ Matthew Desmarais Danek Duvall Ben Finney Martin Fuzzey +Alex Gaynor Carl Gieringer Imri Goldberg Bill Hart diff --git a/CHANGES.txt b/CHANGES.txt index 2dfce50f..3c2b7962 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -9,6 +9,9 @@ Change history for Coverage.py - The ``COVERAGE_OPTIONS`` environment variable is no longer supported. It was a hack for ``--timid`` before configuration files were available. +- Made some PyPy-specific tweaks to improve speed under PyPy. Thanks, Alex + Gaynor. + 4.0a1 --- 27 September 2014 --------------------------- diff --git a/coverage/collector.py b/coverage/collector.py index 66de8b61..001bc3d3 100644 --- a/coverage/collector.py +++ b/coverage/collector.py @@ -24,7 +24,7 @@ except ImportError: CTracer = None try: - import __pypy__ + import __pypy__ # pylint: disable=import-error except ImportError: __pypy__ = None @@ -142,6 +142,20 @@ class Collector(object): # to trace execution in a file. A dict of filename to (filename or # None). if __pypy__ is not None: + # Alex Gaynor said: + # should_trace_cache is a strictly growing key: once a key is in + # it, it never changes. Further, the keys used to access it are + # generally constant, given sufficient context. That is to say, at + # any given point _trace() is called, pypy is able to know the key. + # This is because the key is determined by the physical source code + # line, and that's invariant with the call site. + # + # This property of a dict with immutable keys, combined with + # call-site-constant keys is a match for PyPy's module dict, + # which is optimized for such workloads. + # + # This gives a 20% benefit on the workload described at + # https://bitbucket.org/pypy/pypy/issue/1871/10x-slower-than-cpython-under-coverage self.should_trace_cache = __pypy__.newdict("module") else: self.should_trace_cache = {} |