Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.020 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'args': 0.05; 'python?': 0.05; 'command.': 0.09; 'none:': 0.09; 'skip:[ 20': 0.12; 'wrote:': 0.15; 'literals': 0.16; 'received:192.168.1.40': 0.16; 'argument': 0.16; 'command': 0.19; 'seems': 0.20; 'loop': 0.22; 'header:In-Reply-To:1': 0.22; 'subject:Question': 0.25; 'pass': 0.28; 'modifying': 0.30; 'does': 0.32; 'skip:" 20': 0.33; 'to:addr :python-list': 0.34; 'header:User-Agent:1': 0.34; 'received:192': 0.38; 'subject:: ': 0.38; 'received:192.168.1': 0.39; 'to:addr:python.org': 0.39; 'eliminate': 0.63; 'received:62': 0.67; '(single': 0.84; '100000': 0.84; 'from:addr:t': 0.84; 'spaces.': 0.84 Date: Fri, 22 Jul 2011 14:43:22 +0200 From: Thomas Jollans User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110626 Iceowl/1.0b2 Icedove/3.1.11 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Question about timeit References: <83238f45-e72d-4ea9-9b4a-a42d26cd7282@x7g2000vbk.googlegroups.com> In-Reply-To: X-Enigmail-Version: 1.1.2 OpenPGP: id=5C8691ED Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1311338605 news.xs4all.nl 23931 [2001:888:2000:d::a6]:44397 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:10103 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?