diff options
-rw-r--r-- | Lib/timeit.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/timeit.py b/Lib/timeit.py index 7829395..8c0f7a5 100644 --- a/Lib/timeit.py +++ b/Lib/timeit.py @@ -51,6 +51,7 @@ use python -O for the older versions to avoid timing SET_LINENO instructions. """ +import gc import sys import time try: @@ -155,7 +156,12 @@ class Timer: it = itertools.repeat(None, number) else: it = [None] * number - return self.inner(it, self.timer) + gcold = gc.isenabled() + gc.disable() + timing = self.inner(it, self.timer) + if gcold: + gc.enable() + return timing def repeat(self, repeat=default_repeat, number=default_number): """Call timeit() a few times. |