Antoine Pitrou added the comment:

Le 04/10/2014 17:24, Steven D'Aprano a écrit :
> 
> I know that in general discussions do not need a PEP, but we seem to be 
> rushing awfully fast into writing code before we even know what the code 
> is supposed to do.

Writing a patch is useful practice because it's a way to discover latent
problems (especially when writing unit tests).

> py> Counter(a=1, b=0) < Counter(a=2)
> True
> py> Counter(a=1, b=0) <= Counter(a=2)
> False

That looks wrong to me.

> py> Counter(a=0) <= Counter(b=0)
> True
> py> (Counter(a=0) < Counter(b=0)) or (Counter(a=0) == Counter(b=0))
> False

Ditto.

> py> Counter(a=0) < Counter(b=0)
> False
> py> Counter(a=0) < Counter(b=0, c=0)
> True

Yuck.

> I'm not convinced that mixed Counter and regular dict comparisons should 
> be supported, but Ram's patch supports any Mapping type. Is that a good 
> idea? There's been no discussion on that question.

That sounds wrong to me as well.

> Can somebody explain to me what this means? How is this meaningfully a 
> subset operation?
> 
> py> Counter(a="eggs") < Counter(a="spam")
> True

I agree this looks silly. However, the Counter doc says:

"""The multiset methods are designed only for use cases with positive
values. [...] There are no type restrictions, but the value type needs
to support addition, subtraction, and comparison."""

Which really sounds like an excuse to not perform any type checking and
silently allow nonsensical multiset behaviour with non-integer keys. We
can follow that lead :-)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22515>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to