Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.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.089 X-Spam-Evidence: '*H*': 0.83; '*S*': 0.01; 'constructor': 0.09; 'subject:skip:c 10': 0.09; '(both': 0.16; 'defaultdict': 0.16; 'mro': 0.16; 'subject:slow': 0.16; 'wrote:': 0.18; 'seems': 0.21; 'helper': 0.24; 'mon,': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; "doesn't": 0.30; 'especially': 0.30; 'message-id:@mail.gmail.com': 0.30; 'extend': 0.32; 'but': 0.35; 'received:google.com': 0.35; 'method': 0.36; 'to:addr :python-list': 0.38; 'expect': 0.39; "couldn't": 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'first': 0.61; 'taking': 0.65; 'account': 0.65; 'jul': 0.74; '3.4': 0.84; '2013': 0.98 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=J3OVZmGJt52WP3E2uvMpq9jhbw7ko2vh9X5uE2ULe6Q=; b=e4wszTy49mMpopUUNRohUqte2Z8wk3raCamrliMwPSFyZWdf7jh5Eyo8hzudx86L9n fsLje9V++xBEpksD97C0uBW2tca1RyfpsqPdpjBk81etJmZ+bbRncaWNCg0JotQHSuk3 EIPwZWtpeHtxxkumh52X2iJi5eH1ni/hrSGYB7sIiC383kSZhf9jE4w+IZg+DHByZPIw bc4tiPUEmXxLbQXXMqH+nk0PKRWa+dJbssEhAWDmc8CFWYJvPuOQePWGlVkHs6K8pxRa 6e58UJBrZ1R0mrq5vt7BRGYKH1hiqmBj3606sBH5jrAeuJRvMvZb6XzrfEfRZD9YyI6m 94lQ== X-Received: by 10.66.228.38 with SMTP id sf6mr9056440pac.21.1375118402245; Mon, 29 Jul 2013 10:20:02 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Mon, 29 Jul 2013 11:19:22 -0600 Subject: Re: collections.Counter surprisingly slow To: Python Content-Type: text/plain; charset=ISO-8859-1 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: 9 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375118411 news.xs4all.nl 15984 [2001:888:2000:d::a6]:43332 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51466 On Mon, Jul 29, 2013 at 5:49 AM, Joshua Landau wrote: > Also, couldn't Counter just extend from defaultdict? It could, but I expect the C helper function in 3.4 will be faster since it doesn't even need to call __missing__ in the first place. And the cost (both in terms of maintenance and run-time) of adding defaultdict to the Counter MRO just to reuse one tiny __missing__ method seems questionable, especially after taking into account that the constructor signature is incompatible.