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


Groups > comp.lang.python > #51554

Re: collections.Counter surprisingly slow

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'intermediate': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'repeated': 0.09; 'subject:skip:c 10': 0.09; 'mostly': 0.14; 'optimised': 0.16; 'performances': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:slow': 0.16; 'header :User-Agent:1': 0.23; 'case.': 0.24; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'function': 0.29; 'extend': 0.32; 'agree': 0.35; 'case,': 0.35; 'surely': 0.36; 'method': 0.36; 'should': 0.36; 'two': 0.37; 'performance': 0.37; '8bit%:86': 0.38; 'to:addr:python-list': 0.38; "couldn't": 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'more': 0.64; 'different': 0.65
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Serhiy Storchaka <storchaka@gmail.com>
Subject Re: collections.Counter surprisingly slow
Date Tue, 30 Jul 2013 16:04:12 +0300
References <roy-8C60F5.15590428072013@news.panix.com> <kt51t3$r61$1@ger.gmane.org> <CAN1F8qU9o3Wm43VX0hPXSeYPWY4U73c+xp3q35Z3g664SiZJhA@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host 37.19.175.86
User-Agent Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130623 Thunderbird/17.0.7
In-Reply-To <CAN1F8qU9o3Wm43VX0hPXSeYPWY4U73c+xp3q35Z3g664SiZJhA@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.5305.1375189475.3114.python-list@python.org> (permalink)
Lines 16
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1375189475 news.xs4all.nl 16005 [2001:888:2000:d::a6]:42455
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:51554

Show key headers only | View raw


29.07.13 14:49, Joshua Landau написав(ла):
> I find it hard to agree that counter should be optimised for the
> unique-data case, as surely it's much more oft used when there's a point
> to counting?

Different methods are faster for different data. LBYL approach is best 
for the mostly unique data case, while EAFP approach is best for the 
mostly repeated data case. In general case a performance of particular 
method is a function of its performances in this two extreme cases. When 
it slow for one of extreme case it can be slow in a number of 
intermediate cases.

> Also, couldn't Counter just extend from defaultdict?

Unfortunately this only will slowdown it.

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


Thread

collections.Counter surprisingly slow Roy Smith <roy@panix.com> - 2013-07-28 15:59 -0400
  Re: collections.Counter surprisingly slow Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-28 20:51 +0000
    Re: collections.Counter surprisingly slow Roy Smith <roy@panix.com> - 2013-07-28 17:57 -0400
    Re: collections.Counter surprisingly slow Stefan Behnel <stefan_ml@behnel.de> - 2013-07-29 13:46 +0200
    Re: collections.Counter surprisingly slow Joshua Landau <joshua@landau.ws> - 2013-07-29 13:07 +0100
  Re: collections.Counter surprisingly slow Serhiy Storchaka <storchaka@gmail.com> - 2013-07-29 09:25 +0300
  Re: collections.Counter surprisingly slow Joshua Landau <joshua@landau.ws> - 2013-07-29 12:49 +0100
  Re: collections.Counter surprisingly slow Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-29 11:19 -0600
  Re: collections.Counter surprisingly slow Serhiy Storchaka <storchaka@gmail.com> - 2013-07-29 22:37 +0300
  Re: collections.Counter surprisingly slow Stefan Behnel <stefan_ml@behnel.de> - 2013-07-30 08:39 +0200
  Re: collections.Counter surprisingly slow Stefan Behnel <stefan_ml@behnel.de> - 2013-07-30 08:51 +0200
  Re: collections.Counter surprisingly slow Serhiy Storchaka <storchaka@gmail.com> - 2013-07-30 16:04 +0300

csiph-web