]> granicus.if.org Git - python/commitdiff
Update timeit to use the new string formatting syntax.
authorRaymond Hettinger <python@rcn.com>
Mon, 4 Apr 2011 16:28:25 +0000 (09:28 -0700)
committerRaymond Hettinger <python@rcn.com>
Mon, 4 Apr 2011 16:28:25 +0000 (09:28 -0700)
Lib/timeit.py

index 8e0464526250d29ed9292ba173fa49d5aff41e64..f2510ea2736ae1cf32b831bb1ada0816702a424a 100644 (file)
@@ -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")