Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #15440

Re: all() is slow?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <chris@rebertia.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'run-time': 0.05; 'python': 0.08; 'builtin': 0.09; 'likely.': 0.09; 'runtime': 0.09; 'tends': 0.09; 'developer': 0.12; 'cc:addr:python-list': 0.15; 'mon,': 0.15; 'check?': 0.16; 'myself?': 0.16; 'subject:() ': 0.16; 'cheers,': 0.18; 'wrote:': 0.18; '(which': 0.19; 'cc:no real name:2**0': 0.21; 'unlikely': 0.23; 'header:In-Reply-To:1': 0.23; 'cc:2**0': 0.25; 'expect': 0.25; 'code': 0.25; 'function': 0.27; 'cc:addr:python.org': 0.29; 'message-id:@mail.gmail.com': 0.29; 'cases.': 0.30; 'chris': 0.30; '(e.g.': 0.30; 'subject:?': 0.31; 'nov': 0.31; 'pm,': 0.31; 'regardless': 0.31; 'someone': 0.33; 'latter': 0.34; 'towards': 0.35; 'received:209.85.161': 0.35; 'explain': 0.36; '(to': 0.36; '(not': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; "it's": 0.39; 'subject:: ': 0.39; 'difference': 0.40; 'received:209': 0.40; 'being': 0.40; 'really': 0.40; 'your': 0.61; '2011': 0.62; '1:00': 0.84; 'debunk': 0.84; 'sender:addr:chris': 0.84; 'lean': 0.91; 'to:none': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:cc:content-type :content-transfer-encoding; bh=RuIaWkl7UnNCfat9x/QA1xzMTfg/WPetbG2FnVFuuwA=; b=WtiWO8aduiJUcnwsoIyD3gMrxcGn19/SwayfPH9CDltumPgXaB6MedcBYU0uCQ8BrQ 5MEkRxMUVWl0M1xucHJXU/0xHE1vH0UYy7j1vcXkP9DRJZmW7UnGCrBkViLJGWjaIWiR E4cMy6DcTWKu/hWAY11HWOzxhybTPqZyssobs=
MIME-Version 1.0
Sender chris@rebertia.com
In-Reply-To <Xns9F9684761E3AOKB@88.198.244.100>
References <Xns9F9684761E3AOKB@88.198.244.100>
Date Mon, 7 Nov 2011 13:39:57 -0800
X-Google-Sender-Auth 7LBojTXVBv1Wu1l1ARrCQuRSFFY
Subject Re: all() is slow?
From Chris Rebert <clp2@rebertia.com>
Cc python-list@python.org
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
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.2517.1320702006.27778.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1320702006 news.xs4all.nl 6967 [2001:888:2000:d::a6]:43445
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:15440

Show key headers only | View raw


On Mon, Nov 7, 2011 at 1:00 PM, OKB (not okblacke)
<brenNOSPAMbarn@nobrenspambarn.net> wrote:
<snip>
>        What is the point of the all() function being a builtin if it's
> slower than writing a function to do the check myself?

Regardless of whether it's slower (which I expect someone will be
along to debunk or explain shortly), do you really want to have to
write an additional boilerplate function or block of code /every
single time/ you want to do such a check? The runtime speed difference
is unlikely to be worth your time as a developer in many cases. And by
Murphy's Law, you *will* make errors writing these repetitive code
blocks (e.g. forget to negate the conditional), whereas reusing all()
makes that much less likely.

The trade-off is run-time speed for developer
productivity/convenience; Python tends to lean towards the latter (to
varying degrees).

Cheers,
Chris

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

all() is slow? "OKB (not okblacke)" <brenNOSPAMbarn@NObrenSPAMbarn.net> - 2011-11-07 21:00 +0000
  Re: all() is slow? Chris Rebert <clp2@rebertia.com> - 2011-11-07 13:39 -0800
  Re: all() is slow? david vierra <codewarrior0@gmail.com> - 2011-11-07 13:46 -0800
    Re: all() is slow? Chris Angelico <rosuav@gmail.com> - 2011-11-08 09:06 +1100
      Re: all() is slow? Henrik Faber <hfaber@invalid.net> - 2011-11-08 13:09 +0100
        Re: all() is slow? Chris Angelico <rosuav@gmail.com> - 2011-11-08 23:14 +1100
        Re: all() is slow? John Posner <jjposner@optimum.net> - 2011-11-08 17:51 -0500
        Re: all() is slow? Tim Chase <python.list@tim.thechases.com> - 2011-11-08 17:56 -0600
    Re: all() is slow? Devin Jeanpierre <jeanpierreda@gmail.com> - 2011-11-08 19:44 -0500
      Re: all() is slow? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-11-09 02:47 +0000
        Re: all() is slow? Devin Jeanpierre <jeanpierreda@gmail.com> - 2011-11-09 18:01 -0500
          Re: all() is slow? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-11-09 23:11 +0000
            Re: all() is slow? Devin Jeanpierre <jeanpierreda@gmail.com> - 2011-11-09 20:26 -0500
              Re: all() is slow? alex23 <wuwei23@gmail.com> - 2011-11-09 19:50 -0800
                Re: all() is slow? Devin Jeanpierre <jeanpierreda@gmail.com> - 2011-11-09 23:40 -0500
                Re: all() is slow? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-11-10 07:35 +0000
              Re: all() is slow? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-11-10 07:48 +0000
                Re: all() is slow? Devin Jeanpierre <jeanpierreda@gmail.com> - 2011-11-10 03:51 -0500
                Re: all() is slow? gene heskett <gheskett@wdtv.com> - 2011-11-10 08:20 -0500
                Re: all() is slow? Terry Reedy <tjreedy@udel.edu> - 2011-11-10 14:25 -0500
            Re: all() is slow? Devin Jeanpierre <jeanpierreda@gmail.com> - 2011-11-09 20:35 -0500
            Re: all() is slow? Ian Kelly <ian.g.kelly@gmail.com> - 2011-11-09 19:10 -0700
            Re: all() is slow? Ethan Furman <ethan@stoneleaf.us> - 2011-11-10 10:43 -0800
            Re: all() is slow? Devin Jeanpierre <jeanpierreda@gmail.com> - 2011-11-10 15:37 -0500
              Re: all() is slow? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-11-10 23:07 +0000
                Re: all() is slow? Devin Jeanpierre <jeanpierreda@gmail.com> - 2011-11-10 23:35 -0500
                Re: all() is slow? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-11-12 01:18 +0000
                Re: all() is slow? Devin Jeanpierre <jeanpierreda@gmail.com> - 2011-11-13 01:28 -0500
                Re: all() is slow? alex23 <wuwei23@gmail.com> - 2011-11-13 18:50 -0800
                Re: all() is slow? Devin Jeanpierre <jeanpierreda@gmail.com> - 2011-11-13 23:48 -0500
              Re: all() is slow? "OKB (not okblacke)" <brenNOSPAMbarn@NObrenSPAMbarn.net> - 2011-11-11 05:40 +0000
            Re: all() is slow? Ian Kelly <ian.g.kelly@gmail.com> - 2011-11-10 14:19 -0700
              Re: all() is slow? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-11-10 22:56 +0000
            Re: all() is slow? Ethan Furman <ethan@stoneleaf.us> - 2011-11-10 13:47 -0800
        Re: all() is slow? Chris Angelico <rosuav@gmail.com> - 2011-11-10 10:15 +1100
    Re: all() is slow? Chris Angelico <rosuav@gmail.com> - 2011-11-09 12:19 +1100
    Re: all() is slow? Chris Rebert <clp2@rebertia.com> - 2011-11-08 17:30 -0800
      Re: all() is slow? Hans Mulder <hansmu@xs4all.nl> - 2011-11-09 16:41 +0100
        Re: all() is slow? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-11-09 09:07 -0800
  Re: all() is slow? John Nagle <nagle@animats.com> - 2011-11-09 14:16 -0800
    Re: all() is slow? alex23 <wuwei23@gmail.com> - 2011-11-09 19:52 -0800
    Re: all() is slow? "OKB (not okblacke)" <brenNOSPAMbarn@NObrenSPAMbarn.net> - 2011-11-10 19:35 +0000
  Re: all() is slow? BOOK-AZ <amalguseynov@gmail.com> - 2011-11-15 08:02 -0800

csiph-web