]> granicus.if.org Git - python/commitdiff
Localize the function lookup in timeit.
authorRaymond Hettinger <python@rcn.com>
Fri, 3 Apr 2009 02:47:57 +0000 (02:47 +0000)
committerRaymond Hettinger <python@rcn.com>
Fri, 3 Apr 2009 02:47:57 +0000 (02:47 +0000)
Lib/timeit.py

index c0b08561146522dc205b1ca67024c515b3d354b9..9054243a9bc03ac118931b4c2609148c4fcc59af 100644 (file)
@@ -92,11 +92,11 @@ def reindent(src, indent):
 
 def _template_func(setup, func):
     """Create a timer function. Used if the "statement" is a callable."""
-    def inner(_it, _timer):
+    def inner(_it, _timer, _func=func):
         setup()
         _t0 = _timer()
         for _i in _it:
-            func()
+            _func()
         _t1 = _timer()
         return _t1 - _t0
     return inner