Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder2.ecngs.de!ecngs!feeder.ecngs.de!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed4.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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'fixes': 0.07; 'calls.': 0.09; 'lines.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:skip:c 10': 0.09; 'contribute': 0.11; 'mostly': 0.14; 'dump': 0.16; 'measurement': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'roy': 0.16; 'subject:slow': 0.16; 'input': 0.22; 'tests': 0.22; 'header:User-Agent:1': 0.23; 'affects': 0.24; "shouldn't": 0.24; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'patch': 0.29; 'lines': 0.31; 'file': 0.32; 'totally': 0.33; 'but': 0.35; '8bit%:86': 0.38; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'free': 0.61; 'full': 0.61; 'real': 0.63; 'more': 0.64; 'different': 0.65; 'received:46': 0.66; 'world': 0.66; 'smith': 0.68; 'containing': 0.69; 'repeat': 0.74; 'approach.': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Serhiy Storchaka Subject: Re: collections.Counter surprisingly slow Date: Mon, 29 Jul 2013 09:25:49 +0300 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: 46.211.125.247 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 In-Reply-To: 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375079167 news.xs4all.nl 15928 [2001:888:2000:d::a6]:42489 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51418 28.07.13 22:59, Roy Smith написав(ла): > The input is an 8.8 Mbyte file containing about 570,000 lines (11,000 > unique strings). Repeat you tests with totally unique lines. > The full profiler dump is at the end of this message, but the gist of > it is: Profiler affects execution time. In particular it slowdown Counter implementation which uses more function calls. For real world measurement use different approach. > Why is count() [i.e. collections.Counter] so slow? Feel free to contribute a patch which fixes this "wart". Note that Counter shouldn't be slowdowned on mostly unique data.