summaryrefslogtreecommitdiff
path: root/Lib/timeit.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/timeit.py')
-rwxr-xr-xLib/timeit.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/Lib/timeit.py b/Lib/timeit.py
index d9f9563c2e..2de88f7271 100755
--- a/Lib/timeit.py
+++ b/Lib/timeit.py
@@ -109,19 +109,18 @@ class Timer:
if isinstance(setup, str):
# Check that the code can be compiled outside a function
compile(setup, dummy_src_name, "exec")
+ stmtprefix = setup + '\n'
setup = reindent(setup, 4)
elif callable(setup):
local_ns['_setup'] = setup
init += ', _setup=_setup'
+ stmtprefix = ''
setup = '_setup()'
else:
raise ValueError("setup is neither a string nor callable")
if isinstance(stmt, str):
# Check that the code can be compiled outside a function
- if isinstance(setup, str):
- compile(setup + '\n' + stmt, dummy_src_name, "exec")
- else:
- compile(stmt, dummy_src_name, "exec")
+ compile(stmtprefix + stmt, dummy_src_name, "exec")
stmt = reindent(stmt, 8)
elif callable(stmt):
local_ns['_stmt'] = stmt