Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29332
| References | (3 earlier) <50525f48$0$6573$9b4e6d93@newsspool3.arcor-online.net> <mailman.646.1347575926.27098.python-list@python.org> <5053196e$0$6578$9b4e6d93@newsspool3.arcor-online.net> <mailman.699.1347625166.27098.python-list@python.org> <5055fab1$0$6579$9b4e6d93@newsspool3.arcor-online.net> |
|---|---|
| Date | 2012-09-17 02:19 +1000 |
| Subject | Re: Python presentations |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.804.1347812402.27098.python-list@python.org> (permalink) |
On Mon, Sep 17, 2012 at 2:13 AM, Alexander Blinne <news@blinne.net> 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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python presentations andrea crotti <andrea.crotti.0@gmail.com> - 2012-09-13 17:00 +0100
Re: Python presentations John Gordon <gordon@panix.com> - 2012-09-13 16:06 +0000
Re: Python presentations mblume <foobar@invalid.invalid> - 2012-09-13 16:26 +0000
Re: Python presentations 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-13 12:01 -0700
Re: Python presentations Alexander Blinne <news@blinne.net> - 2012-09-14 00:33 +0200
Re: Python presentations Chris Angelico <rosuav@gmail.com> - 2012-09-14 08:38 +1000
Re: Python presentations 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-13 22:57 -0700
Re: Python presentations 88888 Dihedral <dihedral88888@googlemail.com> - 2012-09-13 22:57 -0700
Re: Python presentations Alexander Blinne <news@blinne.net> - 2012-09-14 13:47 +0200
Re: Python presentations Chris Angelico <rosuav@gmail.com> - 2012-09-14 22:19 +1000
Re: Python presentations Alexander Blinne <news@blinne.net> - 2012-09-16 18:13 +0200
Re: Python presentations Chris Angelico <rosuav@gmail.com> - 2012-09-17 02:19 +1000
Re: Python presentations Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-16 17:35 +0000
Re: Python presentations Alexander Blinne <news@blinne.net> - 2012-09-17 10:39 +0200
Re: Python presentations Miki Tebeka <miki.tebeka@gmail.com> - 2012-09-13 15:58 -0700
Re: Python presentations Andrea Crotti <andrea.crotti.0@gmail.com> - 2012-09-14 00:15 +0100
Re: Python presentations Miki Tebeka <miki.tebeka@gmail.com> - 2012-09-13 15:58 -0700
csiph-web