summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.rst4
-rw-r--r--coverage/ctracer/tracer.c4
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;
}