Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #10103
| Date | 2011-07-22 14:43 +0200 |
|---|---|
| From | Thomas Jollans <t@jollybox.de> |
| Subject | Re: Question about timeit |
| References | (1 earlier) <mailman.1350.1311316646.1164.python-list@python.org> <83238f45-e72d-4ea9-9b4a-a42d26cd7282@x7g2000vbk.googlegroups.com> <j0bb5t$11c$1@r03.glglgl.eu> <mailman.1353.1311323659.1164.python-list@python.org> <ed943cd7-1986-4e09-a062-a084ef623c73@fq4g2000vbb.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1364.1311338605.1164.python-list@python.org> (permalink) |
On 22/07/11 14:30, Frank Millman wrote:
> This is what I get after modifying timeit.py as follows -
>
> if args is None:
> args = sys.argv[1:]
> + print(args)
>
> C:\>python -m timeit int(float('165.0'))
> ["int(float('165.0'))"]
> 100000 loops, best of 3: 3.43 usec per loop
>
> C:\>python -m timeit int(float("165.0"))
> ['int(float(165.0))']
> 1000000 loops, best of 3: 1.97 usec per loop
>
> C:\>python -m timeit "int(float('165.0'))"
> ["int(float('165.0'))"]
> 100000 loops, best of 3: 3.45 usec per loop
>
> It seems that the lesson is -
>
> 1. Use double-quotes around the command itself - may not be necessary
> if the command does not contain spaces.
> 2. Use single-quotes for any literals in the command.
What about 'int(float("165.0"))' (single quotes around the argument)?
Does that pass the single quotes around the argument to Python? Or does
it eliminate all quotes?
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Question about timeit Stefan Behnel <stefan_ml@behnel.de> - 2011-07-22 08:37 +0200
Re: Question about timeit Frank Millman <frank@chagford.com> - 2011-07-21 23:59 -0700
Re: Question about timeit Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-07-22 10:08 +0200
Re: Question about timeit Stefan Behnel <stefan_ml@behnel.de> - 2011-07-22 10:34 +0200
Re: Question about timeit Frank Millman <frank@chagford.com> - 2011-07-22 05:30 -0700
Re: Question about timeit Thomas Jollans <t@jollybox.de> - 2011-07-22 14:43 +0200
Re: Question about timeit Frank Millman <frank@chagford.com> - 2011-07-22 23:30 -0700
csiph-web