diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2015-10-03 22:17:29 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-10-03 22:17:29 -0400 |
commit | 6bf4946e0bc8599a1258c5107f7eece2efa70925 (patch) | |
tree | 7912a27d6f355d0f42981669b60e3490a2851c11 | |
parent | 067544951e8da9dd06478ca221090c506e364a6a (diff) | |
download | python-coveragepy-git-6bf4946e0bc8599a1258c5107f7eece2efa70925.tar.gz |
No more speed penalty for settrace(gettrace()). #397.
-rw-r--r-- | CHANGES.rst | 4 | ||||
-rw-r--r-- | coverage/ctracer/tracer.c | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index 610ea4bf..dbfd1908 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -15,9 +15,13 @@ Version 4.1 are seeing corrupt data files, but this lets them continue combining anyway. Prompted by `issue 418`_. +- Code that uses ``sys.settrace(sys.gettrace())`` used to incur more than a 2x + speed penalty. Now there's no penalty at all. Fixes `issue 397`_. + - Pyexpat C code will no longer be recorded as a source file, fixing `issue 419`_. +.. _issue 397: https://bitbucket.org/ned/coveragepy/issues/397/stopping-and-resuming-coverage-with .. _issue 418: https://bitbucket.org/ned/coveragepy/issues/418/json-parse-error .. _issue 419: https://bitbucket.org/ned/coveragepy/issues/419/nosource-no-source-for-code-path-to-c diff --git a/coverage/ctracer/tracer.c b/coverage/ctracer/tracer.c index 23472575..e5f39d09 100644 --- a/coverage/ctracer/tracer.c +++ b/coverage/ctracer/tracer.c @@ -903,6 +903,10 @@ CTracer_call(CTracer *self, PyObject *args, PyObject *kwds) /* Clean up. */ frame->f_lineno = orig_lineno; + /* For better speed, install ourselves the C way so that future calls go + directly to CTracer_trace, without this intermediate function. */ + PyEval_SetTrace((Py_tracefunc)CTracer_trace, (PyObject*)self); + done: return ret; } |