Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #6978
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.046 |
| X-Spam-Evidence | '*H*': 0.91; '*S*': 0.00; 'pm,': 0.10; 'wrote:': 0.14; '"from': 0.16; '0)"': 0.16; 'functools': 0.16; 'really.': 0.16; 'math': 0.16; 'cc:addr:python-list': 0.17; 'header:In-Reply- To:1': 0.21; 'loop': 0.22; 'cc:2**0': 0.22; 'cc:no real name:2**0': 0.23; 'fri,': 0.23; 'received:209.85.161.46': 0.23; 'received:mail-fx0-f46.google.com': 0.23; 'received:209.85.161': 0.26; 'message-id:@mail.gmail.com': 0.28; 'subject:?': 0.29; 'import': 0.29; 'cc:addr:python.org': 0.30; 'expression': 0.32; 'list': 0.33; 'skip:" 10': 0.35; 'using': 0.35; 'received:google.com': 0.37; 'received:209.85': 0.37; 'but': 0.38; 'subject:: ': 0.38; 'received:209': 0.39; 'really': 0.40; 'best': 0.60; '10000': 0.91; '100000': 0.91; 'gabriel': 0.91; 'subject:Best': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=apC1t49rkbT9dqQkxcRKeuZVCN/q9uZiZmLwEphfXP4=; b=eCESEe3EiCDTPrauuQgM6n31xCcuVMqfL8Go9U1+ZaD/PozuS4UQ6UL8131l08sG/u KaOqTBMSDHlzRcV4Rp496HrAoF3GO/xKw1B4LCdcfVV/BoD6LMKFOm6LQivmf/A2Igtl ou066ACOn80l0fvUmqvUDsSS02u/Uq2xtjxaY= |
| DomainKey-Signature | a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=MfCF1vi98g8XF+/JzB5dagWPHBk3rEYVQww1QD791DI09RxjiKGiBm9W1HSY0wK867 nLQLWkpiuugCuCNC203HLOBxS0/RNZZHaTOU3ObGMqvACmTeBKt4FpwRvz+2PYJSY3ba hf5hnuhfI6D5O93RHe0E84rdBKtDT00OmWLN8= |
| MIME-Version | 1.0 |
| In-Reply-To | <c48d6e64-696a-4d4f-9099-c9137bf25fac@16g2000yqy.googlegroups.com> |
| References | <43d7a46e-3f48-4c11-a66b-a47a3d6b9b9d@k16g2000yqm.googlegroups.com> <mailman.2258.1306749013.9059.python-list@python.org> <a951396d-446b-4ad6-8ad3-d12420e251af@hg8g2000vbb.googlegroups.com> <201106030726.21147.akabaila@pcug.org.au> <mailman.2409.1307056774.9059.python-list@python.org> <c48d6e64-696a-4d4f-9099-c9137bf25fac@16g2000yqy.googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Fri, 3 Jun 2011 16:17:53 -0600 |
| Subject | Re: Best way to compute length of arbitrary dimension vector? |
| To | Gabriel <snoopy.67.z@googlemail.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2441.1307139504.9059.python-list@python.org> (permalink) |
| Lines | 14 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1307139504 news.xs4all.nl 49184 [::ffff:82.94.164.166]:36180 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:6978 |
Show key headers only | View raw
On Fri, Jun 3, 2011 at 3:53 PM, Gabriel <snoopy.67.z@googlemail.com> wrote: > But still, is this solution really faster or better than the one using > list comprehension and the expression 'x*x'? No, not really. >c:\python32\python -m timeit -s "coords = list(range(100))" -s "from math import hypot" -s "from functools import reduce" "reduce(hypot, coords, 0)" 10000 loops, best of 3: 53.2 usec per loop >c:\python32\python -m timeit -s "coords = list(range(100))" -s "from math import sqrt, fsum" "sqrt(fsum(x*x for x in coords))" 10000 loops, best of 3: 32 usec per loop >c:\python32\python -m timeit -s "coords = list(range(100))" -s "from math import sqrt" "sqrt(sum(x*x for x in coords))" 100000 loops, best of 3: 14.4 usec per loop
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Best way to compute length of arbitrary dimension vector? Gabriel <snoopy.67.z@googlemail.com> - 2011-05-30 02:11 -0700
Re: Best way to compute length of arbitrary dimension vector? Chris Rebert <clp2@rebertia.com> - 2011-05-30 02:24 -0700
Re: Best way to compute length of arbitrary dimension vector? Peter Otten <__peter__@web.de> - 2011-05-30 11:46 +0200
Re: Best way to compute length of arbitrary dimension vector? Gabriel <snoopy.67.z@googlemail.com> - 2011-05-30 06:38 -0700
Re: Best way to compute length of arbitrary dimension vector? Ian Kelly <ian.g.kelly@gmail.com> - 2011-06-02 17:19 -0600
Re: Best way to compute length of arbitrary dimension vector? Gabriel <snoopy.67.z@googlemail.com> - 2011-06-03 14:53 -0700
Re: Best way to compute length of arbitrary dimension vector? Ian Kelly <ian.g.kelly@gmail.com> - 2011-06-03 16:17 -0600
Re: Best way to compute length of arbitrary dimension vector? Robert Kern <robert.kern@gmail.com> - 2011-06-03 18:12 -0500
Re: Best way to compute length of arbitrary dimension vector? "Gabriel Genellina" <gagsl-py2@yahoo.com.ar> - 2011-05-30 16:01 -0300
Re: Best way to compute length of arbitrary dimension vector? Gabriel <snoopy.67.z@googlemail.com> - 2011-06-01 12:35 -0700
csiph-web