[pypy-issue] [issue946] timeit-as-CLI does not accept import

Xavier Morel tracker at bugs.pypy.org
Wed Nov 30 11:46:42 CET 2011

New submission from Xavier Morel <bugs.pypy.org at masklinn.net>:

> python2.7 --version
Python 2.7.2
> python2.7 -mtimeit -s 'import random' 'random.random()'   
10000000 loops, best of 3: 0.116 usec per loop
> pypy-c --version   
Python 2.7.1 (?, Nov 24 2011, 10:57:50)
[PyPy 1.7.0]
> pypy-c -mtimeit -s 'import random' 'random.random()'          
Traceback (most recent call last):
  File "app_main.py", line 51, in run_toplevel
  File "/opt/local/lib/pypy/lib-python/2.7/runpy.py", line 162, in _run_module_as_
    "__main__", fname, loader, pkg_name)
  File "/opt/local/lib/pypy/lib-python/2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/opt/local/lib/pypy/lib-python/2.7/timeit.py", line 328, in <module>
  File "/opt/local/lib/pypy/lib-python/2.7/timeit.py", line 292, in main
    t = Timer(stmt, setup, timer)
  File "/opt/local/lib/pypy/lib-python/2.7/timeit.py", line 136, in __init__
    code = compile(src, dummy_src_name, "exec")
  File "<timeit-src>", line 3
SyntaxError: invalid syntax

This precludes the (pretty useful) use as the command-line timeit to see very
basic synthetic performance tests on various library (standard or not) code samples.

messages: 3513
nosy: masklinn, pypy-issue
priority: bug
status: unread
title: timeit-as-CLI does not accept import

PyPy bug tracker <tracker at bugs.pypy.org>

More information about the pypy-issue mailing list