[Python-ideas] collections.Counter multiplication

Andrew Barnert abarnert at yahoo.com
Thu May 30 08:31:21 CEST 2013


On May 29, 2013, at 22:48, David Mertz <mertz at gnosis.cx> wrote:

> However, I don't think so with collections.abc.Mapping--in that case I deliberately chose collections.Counter because the semantics seemed undefined in other cases.
> 
> That is, I have no idea what meaning the OP would assign to:
> 
> >>> Counter({'a':1,'b':2}) * OrderedDict((('a','x'),('b','y')))

My immediate thought was TypeError.

And then I went away for a few minutes, reread it, and my immediate thought was {'a': 'x', 'b': 'yy'} or the Ordered equivalent thereof.

Which I think proves your point.

Honestly, I understand this half of the proposal far less than the scalar version. Any numpy or pandas user would find that obvious, and I can't imagine anything else it could mean. The Counter*Counter, I have no intuition for at all. 


More information about the Python-ideas mailing list