Commit ddc42815 authored by Raymond Hettinger's avatar Raymond Hettinger

Localize the function lookup in timeit.

parent dfa23ed6
...@@ -92,11 +92,11 @@ def reindent(src, indent): ...@@ -92,11 +92,11 @@ def reindent(src, indent):
def _template_func(setup, func): def _template_func(setup, func):
"""Create a timer function. Used if the "statement" is a callable.""" """Create a timer function. Used if the "statement" is a callable."""
def inner(_it, _timer): def inner(_it, _timer, _func=func):
setup() setup()
_t0 = _timer() _t0 = _timer()
for _i in _it: for _i in _it:
func() _func()
_t1 = _timer() _t1 = _timer()
return _t1 - _t0 return _t1 - _t0
return inner return inner
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment