[Python-checkins] cpython: Update timeit to use the new string formatting syntax.
raymond.hettinger
python-checkins at python.org
Mon Apr 4 18:30:23 CEST 2011
http://hg.python.org/cpython/rev/81c981ceb83e
changeset: 69131:81c981ceb83e
user: Raymond Hettinger <python at rcn.com>
date: Mon Apr 04 09:28:25 2011 -0700
summary:
Update timeit to use the new string formatting syntax.
files:
Lib/timeit.py | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Lib/timeit.py b/Lib/timeit.py
--- a/Lib/timeit.py
+++ b/Lib/timeit.py
@@ -79,10 +79,10 @@
# 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 @@
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")
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list