Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.mixmin.net!feed.xsnews.nl!border-2.ams.xsnews.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.05; 'sep': 0.09; 'successive': 0.09; 'def': 0.10; '*any*': 0.16; 'alexander': 0.16; 'comp': 0.16; 'frankly': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'massively': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'bit': 0.21; 'assuming': 0.22; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'usually': 0.30; 'function': 0.30; 'raising': 0.33; 'to:addr:python-list': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'list': 0.35; 'received:209.85': 0.35; 'really': 0.36; 'except': 0.36; 'but': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'instead': 0.39; 'performance': 0.39; 'to:addr:python.org': 0.39; 'takes': 0.39; 'header:Received:5': 0.40; 'think': 0.40; 'surprise': 0.65; 'unusual': 0.71; 'iterative': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=j6W9JDgRGfHSrZywFDeDBsRtuyFUUfChV35Jo1bElZs=; b=PiQ84DpEiJNTeMAmi1XjeoG/BK2Z3OQSNtr5IHH/MIPBzzaBClImyAw2JBHkXEOLNG S9MB/0UVjuJg1jHayGiQist4GchY39vNTyuvkzywJ6przmiAbtFXq6HBh8+3sfLf2SlR LJ4/Wg7YXQ4Oadtt7LaXmOPO2Efmug9ALihjUvU6fB/OZdek4QQ9yhU6NpC9oMFEc8so yDu+HAjhQYKj+J3B3Tpxj+7rB0l07gW3dIwq0SsSM4CPAPWte6C78TqhSvYZvcFuWOvV GsxxGDojGvTp3M0XynkOo03YcXakZw7Q7Hn4r7pA+EUZfAC0qllDP5IE8nqkKJ249xFz 2bbg== MIME-Version: 1.0 In-Reply-To: <5055fab1$0$6579$9b4e6d93@newsspool3.arcor-online.net> References: <06a1a81b-246b-4e7b-ba34-4701f46889c8@googlegroups.com> <50525f48$0$6573$9b4e6d93@newsspool3.arcor-online.net> <5053196e$0$6578$9b4e6d93@newsspool3.arcor-online.net> <5055fab1$0$6579$9b4e6d93@newsspool3.arcor-online.net> Date: Mon, 17 Sep 2012 02:19:58 +1000 Subject: Re: Python presentations From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1347812402 news.xs4all.nl 6879 [2001:888:2000:d::a6]:40791 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29332 On Mon, Sep 17, 2012 at 2:13 AM, Alexander Blinne wrote: > def powerlist3(x,n): > return [x**i for i in xrange(n)] > > for really big n powerlist3 always takes very much time :) I would reiterate that a really big n is a really unusual use case for a function like this, except that... I frankly can't think of *any* use case for it!! But for many many applications, the simplicity and readability of a list comp instead of a function is usually going to outweigh the performance differences. However, it doesn't surprise me that individually raising a number to successive powers is slower than iterative multiplication, assuming you can't massively optimize eg with powers of 2 and bit shifts. ChrisA