Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'element': 0.07; '*is*': 0.09; 'latter': 0.09; 'negative.': 0.09; 'python': 0.11; 'distinct': 0.16; 'equality.': 0.16; 'implies': 0.16; 'integer,': 0.16; 'keys.': 0.16; 'multiset.': 0.16; 'numbers;': 0.16; 'set,': 0.16; 'wrote:': 0.18; 'seems': 0.21; 'email addr:gmail.com>': 0.22; "i've": 0.25; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'fine,': 0.31; 'restricted': 0.31; 'not.': 0.33; 'except': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'detail': 0.37; 'being': 0.38; 'skip:& 10': 0.38; 'nov': 0.38; 'to:addr:python- list': 0.38; 'skip:& 20': 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'liked': 0.60; 'today,': 0.61; 'term': 0.63; 'skip:n 10': 0.64; 'natural': 0.68; 'bag': 0.74; 'all;': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=L1tiNljTNNt5ZcffH8Ud64mge1lZ032LwMpsDlcJW1k=; b=0KDajXkQ2dGc4phKg9ngbLQSeQE0Sea7HEV44eh7Yu6IThBagtEZfOdTV2hCrbYIGa /cs0Cc+PIQAEoCFNcEiI67jyvv3HpbEx+dsb5LPe9fQtwHiXp1kqXfzcUvC0+WWXikPa qspbh5TAY4xpMYvHxLMqdR17UQf875NbwXW7EkoTITB/h1Ccs1biEgLd5xJfV81cPr08 7emEtyOQrDN42McodkGqNxJ8YZpHKdwKPBKloikV4z3AuFjETj3+baz9cMsLlBFUizMv j+QhA/zyxvKEn06ekeDoComOJuq5uBONdOSWiCr0s8mNo2uRx8M+ZRADDut5auo7mvQw psHg== MIME-Version: 1.0 X-Received: by 10.66.146.71 with SMTP id ta7mr9726565pab.16.1415336700728; Thu, 06 Nov 2014 21:05:00 -0800 (PST) In-Reply-To: References: Date: Thu, 6 Nov 2014 22:05:00 -0700 Subject: Re: Real-world use of Counter From: Ian Kelly To: Python Content-Type: multipart/alternative; boundary=047d7b6da6ee48dc1e05073dc1c5 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: 61 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1415337021 news.xs4all.nl 2860 [2001:888:2000:d::a6]:51196 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80348 --047d7b6da6ee48dc1e05073dc1c5 Content-Type: text/plain; charset=UTF-8 On Nov 6, 2014 10:51 AM, "Ian Kelly" wrote: > > On Nov 6, 2014 1:06 AM, "Rustom Mody" wrote: > > Calling a bag as counter is inappropriate for an analogous reason > > to why calling a dictionary as a 'hash' is inappropriate -- > > it confuses an implementation detail for fundamental semantics. > > I've never liked the term "bag". In addition to being nonstandard it's also very nonintuitive. "Multiset" is fine, except that it implies the collection is a type of set, which the Python Counter is not. I was thinking about this today, and it seems to me that the Python Counter is not really even a multiset. * The size of a multiset would be the count of all the elements; the len of a Counter is only the number of keys. * The multiplicity of an element in a multiset is restricted to the natural numbers; the count of an element in a Counter can be any integer, even negative. * In a Counter, a key with a count of 0 is a distinct state from a key not being present at all; in the latter case the element is not in the Counter, while in the former case it *is* in the Counter. These states are also distinct for the purpose of equality. --047d7b6da6ee48dc1e05073dc1c5 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Nov 6, 2014 10:51 AM, "Ian Kelly" <ian.g.kelly@gmail.com> wrote:
>
> On Nov 6, 2014 1:06 AM, "Rustom Mody" <rustompmody@gmail.com> wrote:
> > Calling a bag as counter is inappropriate for an analogous reason=
> > to why calling a dictionary as a 'hash' is inappropriate = --
> > it confuses an implementation detail for fundamental semantics. >
> I've never liked the term "bag". In addition to being no= nstandard it's also very nonintuitive. "Multiset" is fine, ex= cept that it implies the collection is a type of set, which the Python Coun= ter is not.

I was thinking about this today, and it seems to me that the= Python Counter is not really even a multiset.

* The size of a multiset would be the count of all the eleme= nts; the len of a Counter is only the number of keys.
* The multiplicity of an element in a multiset is restricted to the natural= numbers; the count of an element in a Counter can be any integer, even neg= ative.
* In a Counter, a key with a count of 0 is a distinct state from a key not = being present at all; in the latter case the element is not in the Counter,= while in the former case it *is* in the Counter. These states are also dis= tinct for the purpose of equality.

--047d7b6da6ee48dc1e05073dc1c5--