summaryrefslogtreecommitdiffstats
path: root/Lib/timeit.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-04-04 16:28:25 (GMT)
committerRaymond Hettinger <python@rcn.com>2011-04-04 16:28:25 (GMT)
commitc800af41c909a9cd90ccabdf88ed4db96446fb4b (patch)
tree27116ac4bf3f8ef37cada24c83ae2dc747235986 /Lib/timeit.py
parentf7ec1698a244a7b560f27f6da877937d3c34c18c (diff)
downloadcpython-c800af41c909a9cd90ccabdf88ed4db96446fb4b.zip
cpython-c800af41c909a9cd90ccabdf88ed4db96446fb4b.tar.gz
cpython-c800af41c909a9cd90ccabdf88ed4db96446fb4b.tar.bz2
Update timeit to use the new string formatting syntax.
Diffstat (limited to 'Lib/timeit.py')
-rw-r--r--Lib/timeit.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/timeit.py b/Lib/timeit.py
index 8e04645..f2510ea 100644
--- a/Lib/timeit.py
+++ b/Lib/timeit.py
@@ -79,10 +79,10 @@ else:
# being indented 8 spaces.
template = """
def inner(_it, _timer):
- %(setup)s
+ {setup}
_t0 = _timer()
for _i in _it:
- %(stmt)s
+ {stmt}
_t1 = _timer()
return _t1 - _t0
"""
@@ -126,9 +126,9 @@ class Timer:
stmt = reindent(stmt, 8)
if isinstance(setup, str):
setup = reindent(setup, 4)
- src = template % {'stmt': stmt, 'setup': setup}
+ src = template.format(stmt=stmt, setup=setup)
elif hasattr(setup, '__call__'):
- src = template % {'stmt': stmt, 'setup': '_setup()'}
+ src = template.format(stmt=stmt, setup='_setup()')
ns['_setup'] = setup
else:
raise ValueError("setup is neither a string nor callable")