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


Groups > comp.lang.python > #80337

Re: Real-world use of Counter

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!bcyclone04.am1.xlned.com!bcyclone04.am1.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.105
X-Spam-Level *
X-Spam-Evidence '*H*': 0.79; '*S*': 0.00; 'python': 0.11; 'cs,': 0.16; 'fine.': 0.16; 'heap,': 0.16; 'implies': 0.16; 'overloaded': 0.16; 'repetition': 0.16; 'set,': 0.16; 'weird': 0.16; 'wrote:': 0.18; 'programming': 0.22; 'email addr:gmail.com&gt;': 0.22; 'stick': 0.24; "i've": 0.25; '&gt;': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'sets': 0.30; 'message-id:@mail.gmail.com': 0.30; 'that.': 0.31; 'fine,': 0.31; 'lists': 0.32; 'compatible': 0.32; 'not.': 0.33; 'except': 0.35; 'case,': 0.35; 'received:google.com': 0.35; 'detail': 0.37; 'being': 0.38; 'sometimes': 0.38; 'skip:& 10': 0.38; 'nov': 0.38; 'to:addr :python-list': 0.38; 'list,': 0.38; 'skip:& 20': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'liked': 0.60; 'hardware': 0.61; 'name': 0.63; 'term': 0.63; 'skip:n 10': 0.64; 'world': 0.66; 'design.': 0.68; 'bag': 0.74; 'bags': 0.84; 'describes': 0.84; 'studying': 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=2WWxKF16/QTXtTS9WiJq0Ft+MTwOzjkrE9EugBPYVys=; b=BmAEbzDCAo22envBX1m/y1XHUi6PaUtFdhrCowbpRd4bEkPfXDPsVzp42wl1sBsM6W ZlMhjM5XEOehi4XH/Mmf4H6r7zzkQeOlDLy1yGFbBxNPpbh/J5BbkUIkPFUD20/Ccf6B XajgAigeYLo5HR4JjcxaFCMH/mjXSKL5Ngxp/KCnpNZl23xDQ1III7FpkHENTEkzMex5 wSFvcWVuk09c5hUzlXJjtgMQG/FSYGo2ParkDFQqmfShniw43oME2s820lXqBJ+sNN23 i2V0xIASCXW0xmohS9zK28wdkoBzqtgaokIM4nEbAKbCmR/b6S4koQpPoPzd3mAkJyLy C+2A==
MIME-Version 1.0
X-Received by 10.68.111.161 with SMTP id ij1mr5410048pbb.10.1415289080663; Thu, 06 Nov 2014 07:51:20 -0800 (PST)
In-Reply-To <f28f7279-ac82-4a14-a433-561daec1efb2@googlegroups.com>
References <mailman.15504.1415204817.18130.python-list@python.org> <f28f7279-ac82-4a14-a433-561daec1efb2@googlegroups.com>
Date Thu, 6 Nov 2014 08:51:20 -0700
Subject Re: Real-world use of Counter
From Ian Kelly <ian.g.kelly@gmail.com>
To Python <python-list@python.org>
Content-Type multipart/alternative; boundary=047d7b5db7fae856d6050732aa0e
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.15548.1415290928.18130.python-list@python.org> (permalink)
Lines 67
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1415290928 news.xs4all.nl 2877 [2001:888:2000:d::a6]:37960
X-Complaints-To abuse@xs4all.nl
X-Received-Bytes 6547
X-Received-Body-CRC 414819229
Xref csiph.com comp.lang.python:80337

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Nov 6, 2014 1:06 AM, "Rustom Mody" <rustompmody@gmail.com> wrote:
> In studying (somewhat theoretically) the general world of
> collection data structures we see
> - sets  -- neither order nor repetition
> - bags  -- no order, repetition significant
> - lists -- both order and repetition
>
> Sometimes 'bag' is called 'multiset'
> However counter is a weird non-standard name that overloads
> an already overloaded term -- 'Counter' has a very standard meaning in
programming and in hardware design.

"Bag" is also nonstandard. Other nonstandard names for the same type
include list, heap, bunch, sample, weighted set, occurrence set and
fireset. Knuth uses multiset, so let's stick with that.

As for Counter already having meanings in CS, the Python Counter is
compatible with those.

> 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.

The name "Counter" describes the intended use case, not the implementation,
so I think it's fine.

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


Thread

Real-world use of Counter Ethan Furman <ethan@stoneleaf.us> - 2014-11-05 08:26 -0800
  Re: Real-world use of Counter Rustom Mody <rustompmody@gmail.com> - 2014-11-05 22:00 -0800
    Re: Real-world use of Counter Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-06 08:51 -0700
    Re: Real-world use of Counter Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-06 22:05 -0700

csiph-web