Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #89772
| Path | csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.036 |
| X-Spam-Evidence | '*H*': 0.93; '*S*': 0.00; 'subject:not': 0.03; 'operator': 0.03; 'subject:Python': 0.06; 'python': 0.11; 'def': 0.12; '4:35': 0.16; 'iterable,': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'library': 0.18; 'import': 0.22; 'replace': 0.24; 'header :In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "can't": 0.35; 'possible.': 0.35; 'definition': 0.35; 'operations': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'really': 0.36; 'performance': 0.37; 'version,': 0.38; 'to:addr :python-list': 0.38; 'does': 0.39; 'delete': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'dave': 0.60; 'range': 0.61; 'first': 0.61; 'worth': 0.66; 'gain': 0.79; '2015': 0.84; 'iterative': 0.84; 'angel': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=HqijTLxJZEb4QDh7Rch5a5PhGrhRR89BI5E+VzjHxBc=; b=sDqibika2f6bKwBsBaACyIm6nr6NjscJz2D7NRELaCsh6/cBPyd6cWSrcWnE24kU8r n+AiIRLDZ83Z75uwwNu5+TebulvteyiCQPVRPKuuijDkftt0ziqDGvmNArcWqspI0IyJ qWVLnSgQtBX1wnnD4mdGDPOH1JtIm4WQuywaEo7GoCsHK33eDp5jxmwFGt16kH6ow1kw li9PEaKhuGCNHtnTE/P73gUfrHC8iIVsQV354vDMv1/QGr5Rxwn0i6gVpO7QCwO6kqEB GS9DaqESO1SGV7bFawqD+ycc74tnmG5jEHpyUoXSGpzVlvwmFO9clTGcaulJjt4ZZfx/ mLyw== |
| X-Received | by 10.107.12.158 with SMTP id 30mr4554628iom.61.1430580758341; Sat, 02 May 2015 08:32:38 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <5544A85F.5080805@davea.name> |
| References | <87mw1q9jqw.fsf@Equus.decebal.nl> <mailman.121.1430385051.3680.python-list@python.org> <87383hj4zj.fsf@elektro.pacujo.net> <87d22lx38x.fsf@Equus.decebal.nl> <55432557$0$12994$c3e8da3$5496439d@news.astraweb.com> <87383fo062.fsf@Equus.decebal.nl> <87twvvmigr.fsf@Equus.decebal.nl> <5544A85F.5080805@davea.name> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Sat, 2 May 2015 09:31:57 -0600 |
| Subject | Re: Python is not bad ;-) |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.11.1430580760.12865.python-list@python.org> (permalink) |
| Lines | 21 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1430580760 news.xs4all.nl 2854 [2001:888:2000:d::a6]:49321 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:89772 |
Show key headers only | View raw
On Sat, May 2, 2015 at 4:35 AM, Dave Angel <davea@davea.name> wrote:
> I can't see how that is worth doing. The recursive version is already a
> distortion of the definition of factorial that I learned. And to force it
> to be recursive and also contort it so it does the operations in the same
> order as the iterative version, just to gain performance?
>
> If you want performance on factorial, write it iteratively, in as
> straightforward a way as possible. Or just call the library function.
Or if you really want to write it functionally:
from functools import reduce
from operator import mul
def product(iterable):
return reduce(mul, iterable, 1)
def factorial(n):
return product(range(1, n+1))
For Python 2, delete the first import and replace range with xrange.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python is not bad ;-) Cecil Westerhof <Cecil@decebal.nl> - 2015-04-30 09:07 +0200
Re: Python is not bad ;-) Ben Finney <ben+python@benfinney.id.au> - 2015-04-30 19:10 +1000
Re: Python is not bad ;-) Marko Rauhamaa <marko@pacujo.net> - 2015-04-30 13:16 +0300
Re: Python is not bad ;-) Chris Angelico <rosuav@gmail.com> - 2015-04-30 20:52 +1000
Re: Python is not bad ;-) Cecil Westerhof <Cecil@decebal.nl> - 2015-04-30 13:30 +0200
Re: Python is not bad ;-) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-01 17:03 +1000
Re: Python is not bad ;-) Cecil Westerhof <Cecil@decebal.nl> - 2015-05-01 09:47 +0200
Re: Python is not bad ;-) Christian Gollwitzer <auriocus@gmx.de> - 2015-05-01 19:56 +0200
Re: Python is not bad ;-) Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2015-05-02 19:44 +1200
Re: Python is not bad ;-) Cecil Westerhof <Cecil@decebal.nl> - 2015-05-02 10:26 +0200
Re: Python is not bad ;-) Marko Rauhamaa <marko@pacujo.net> - 2015-05-02 12:10 +0300
Re: Python is not bad ;-) Chris Angelico <rosuav@gmail.com> - 2015-05-02 19:25 +1000
Re: Python is not bad ;-) Marko Rauhamaa <marko@pacujo.net> - 2015-05-02 12:58 +0300
Re: Python is not bad ;-) Dave Angel <davea@davea.name> - 2015-05-02 06:22 -0400
Re: Python is not bad ;-) Chris Angelico <rosuav@gmail.com> - 2015-05-02 20:42 +1000
Re: Python is not bad ;-) Christian Gollwitzer <auriocus@gmx.de> - 2015-05-02 13:07 +0200
Re: Python is not bad ;-) Chris Angelico <rosuav@gmail.com> - 2015-05-02 21:21 +1000
Re: Python is not bad ;-) Christian Gollwitzer <auriocus@gmx.de> - 2015-05-02 13:32 +0200
Re: Python is not bad ;-) Marko Rauhamaa <marko@pacujo.net> - 2015-05-02 14:42 +0300
Re: Python is not bad ;-) Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-02 09:45 -0600
Re: Python is not bad ;-) Chris Angelico <rosuav@gmail.com> - 2015-05-03 01:55 +1000
Re: Python is not bad ;-) Joonas Liik <liik.joonas@gmail.com> - 2015-05-02 16:50 +0300
Re: Python is not bad ;-) Joonas Liik <liik.joonas@gmail.com> - 2015-05-02 18:53 +0300
Re: Python is not bad ;-) Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-02 11:00 -0600
Re: Python is not bad ;-) Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-02 11:17 -0600
Re: Python is not bad ;-) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-02 18:22 +0100
Re: Python is not bad ;-) Cecil Westerhof <Cecil@decebal.nl> - 2015-05-02 12:29 +0200
Re: Python is not bad ;-) Cecil Westerhof <Cecil@decebal.nl> - 2015-05-02 11:33 +0200
Re: Python is not bad ;-) Dave Angel <davea@davea.name> - 2015-05-02 06:35 -0400
Re: Python is not bad ;-) Cecil Westerhof <Cecil@decebal.nl> - 2015-05-02 13:12 +0200
Re: Python is not bad ;-) Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-02 09:31 -0600
Re: Python is not bad ;-) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-01 15:56 +1000
Re: Python is not bad ;-) Cecil Westerhof <Cecil@decebal.nl> - 2015-04-30 13:10 +0200
Re: Python is not bad ;-) Michael Torrie <torriem@gmail.com> - 2015-04-30 08:03 -0600
Re: Python is not bad ;-) Cecil Westerhof <Cecil@decebal.nl> - 2015-04-30 18:11 +0200
Re: Python is not bad ;-) Christian Gollwitzer <auriocus@gmx.de> - 2015-04-30 19:59 +0200
Re: Python is not bad ;-) Cecil Westerhof <Cecil@decebal.nl> - 2015-04-30 22:05 +0200
csiph-web