Re: Counter Class -- Bag/Multiset

2009-01-24 Thread pataphor
On Thu, 22 Jan 2009 10:11:37 -0800 (PST) Raymond Hettinger wrote: > The collections module in Python 2.7 and Python 3.1 has gotten a new > Counter class that works like bags and multisets in other languages. I like that! Now that we have a multiset or Counter I think a redefinition of itertools.

Re: Counter Class -- Bag/Multiset

2009-01-23 Thread MRAB
Terry Reedy wrote: bearophileh...@lycos.com wrote: Also: what's the rationale of allowing negative values too? I can guess two: 1) Nuisance to check given that Python does not have a count (0,1,2...) type. 2. Useful. + = items on hand; - = items back-ordered. Bank account go negative also ;-)

Re: Counter Class -- Bag/Multiset

2009-01-23 Thread Giovanni Bajo
On 1/23/2009 2:49 AM, Chris Rebert wrote: On Thu, Jan 22, 2009 at 5:41 PM, Giovanni Bajo wrote: On Thu, 22 Jan 2009 10:11:37 -0800, Raymond Hettinger wrote: The collections module in Python 2.7 and Python 3.1 has gotten a new Counter class that works like bags and multisets in other languages

Re: Counter Class -- Bag/Multiset

2009-01-23 Thread Terry Reedy
bearophileh...@lycos.com wrote: Also: what's the rationale of allowing negative values too? I can guess two: 1) Nuisance to check given that Python does not have a count (0,1,2...) type. 2. Useful. + = items on hand; - = items back-ordered. Bank account go negative also ;-). So does elevatio

Re: Counter Class -- Bag/Multiset

2009-01-23 Thread Terry Reedy
msrache...@gmail.com wrote: The term counter was what was originally approved. At first, I didn't like it but found that it had some advantages. The main advantage is that there are *bazillions* of programmers (including some very good ones) who have never heard the term multiset or bag but ha

Re: Counter Class -- Bag/Multiset

2009-01-23 Thread msrachel . e
On Jan 23, 12:27 am, bearophileh...@lycos.com wrote: > bearophile: > > > Are keys restricted to be long and int values only? Or are they > > general (referenced) objects + a control of their integral nature? > > Here I meant values, sorry. > Also: what's the rationale of allowing negative values to

Re: Counter Class -- Bag/Multiset

2009-01-23 Thread bearophileHUGS
bearophile: > Are keys restricted to be long and int values only? Or are they > general (referenced) objects + a control of their integral nature? Here I meant values, sorry. Also: what's the rationale of allowing negative values too? Bye, bearophile -- http://mail.python.org/mailman/listinfo/pyt

Re: Counter Class -- Bag/Multiset

2009-01-23 Thread bearophileHUGS
Raymond Hettinger: > The collections module in Python 2.7 and Python 3.1 has gotten a new > Counter class that works like bags and multisets in other languages. Very nice. Python std lib is growing more data structures, increasing the power of a default Python installation. I can remove more and m

Re: Counter Class -- Bag/Multiset

2009-01-23 Thread Paul Rubin
msrache...@gmail.com writes: > how do you guys like the functionality? Do you find it useable in > real-world use cases? It's interesting. I wouldn't have thought of that API--I'm used to populating defaultdict(int) in the obvious ways for this sort of thing--but it is attractive and I think it

Re: Counter Class -- Bag/Multiset

2009-01-22 Thread msrachel . e
On Jan 22, 5:54 pm, Paul Rubin wrote: > Giovanni Bajo writes: > > * I'm not a native speaker, but why use the word "Counter"? > > I agree with this, the new functionality is welcome but I think > the traditional term "multiset" or "bag" would have been better. The t

Re: Counter Class -- Bag/Multiset

2009-01-22 Thread msrachel . e
On Jan 22, 5:41 pm, Giovanni Bajo wrote: > * I find it *very* confusing c.items() vs c.elements(). Items and > elements are synonymous (again, in my understanding of English). Would have used the term "items" but that term has a different meaning in the context of dictionaries where "items" means

Re: Counter Class -- Bag/Multiset

2009-01-22 Thread Terry Reedy
Chris Rebert wrote: On Thu, Jan 22, 2009 at 5:41 PM, Giovanni Bajo wrote: On Thu, 22 Jan 2009 10:11:37 -0800, Raymond Hettinger wrote: The collections module in Python 2.7 and Python 3.1 has gotten a new Counter class that works like bags and multisets in other languages. I've adapted it for

Re: Counter Class -- Bag/Multiset

2009-01-22 Thread Benjamin Kaplan
> Hi Raymond, > > * I'm not a native speaker, but why use the word "Counter"? A "counter" > to my ear sounds like a number that is increased each time an event > occurs; the website counter, eg, comes to mind. I can understanda its > meaning probably stretches to "an object that counts", but I real

Re: Counter Class -- Bag/Multiset

2009-01-22 Thread Paul Rubin
Giovanni Bajo writes: > * I'm not a native speaker, but why use the word "Counter"? I agree with this, the new functionality is welcome but I think the traditional term "multiset" or "bag" would have been better. -- http://mail.python.org/mailman/listinfo/python-list

Re: Counter Class -- Bag/Multiset

2009-01-22 Thread Chris Rebert
On Thu, Jan 22, 2009 at 5:41 PM, Giovanni Bajo wrote: > On Thu, 22 Jan 2009 10:11:37 -0800, Raymond Hettinger wrote: > >> The collections module in Python 2.7 and Python 3.1 has gotten a new >> Counter class that works like bags and multisets in other languages. >> >> I've adapted it for Python2.5

Re: Counter Class -- Bag/Multiset

2009-01-22 Thread Giovanni Bajo
On Thu, 22 Jan 2009 10:11:37 -0800, Raymond Hettinger wrote: > The collections module in Python 2.7 and Python 3.1 has gotten a new > Counter class that works like bags and multisets in other languages. > > I've adapted it for Python2.5/2.6 so people can start using it right > away: > http://do

Re: Counter Class -- Bag/Multiset

2009-01-22 Thread Raymond Hettinger
> That should just be Python2.6. Fixed. Now runs of Python 2.5 as well. -- http://mail.python.org/mailman/listinfo/python-list

Re: Counter Class -- Bag/Multiset

2009-01-22 Thread Raymond Hettinger
> I've adapted it for Python2.5/2.6 so people can start using it right > away: That should just be Python2.6. -- http://mail.python.org/mailman/listinfo/python-list

Counter Class -- Bag/Multiset

2009-01-22 Thread Raymond Hettinger
The collections module in Python 2.7 and Python 3.1 has gotten a new Counter class that works like bags and multisets in other languages. I've adapted it for Python2.5/2.6 so people can start using it right away: http://docs.python.org/dev/library/collections.html#counter-objects Here's a link