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

index 5ce9b4ac47f29fc48544b2cea5b99016adad6886..7b9b72c82e9473af548a8e64416f05d5fe0efc02 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