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


Groups > comp.lang.python > #80337

Re: Real-world use of Counter

References <mailman.15504.1415204817.18130.python-list@python.org> <f28f7279-ac82-4a14-a433-561daec1efb2@googlegroups.com>
Date 2014-11-06 08:51 -0700
Subject Re: Real-world use of Counter
From Ian Kelly <ian.g.kelly@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.15548.1415290928.18130.python-list@python.org> (permalink)

Show all headers | 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