[Python-ideas] Counter comparison
Ethan Furman
ethan at stoneleaf.us
Sun Nov 23 16:40:46 CET 2014
On 11/22/2014 09:33 PM, Nick Coghlan wrote:
>
> With the existing Counter-as-multiset features already offering some
> potential for confusion, and the potential for further confusing
> interactions between additional multiset features and Counter's
> support for non-integer values, zero values (distinct from keys being
> missing entirely) and negative values, there may be scope for a
> separate true multiset API that draws more heavily on the set API
> design than the dict API design.
>
> A dedicated multiset API would potentially be able to avoid the
> confusing aspects of Counters-as-multisets by only allowing
> non-negative integer values. Is there sufficient value in such an API
> to justify adding it? Or would it just create confusion as folks tried
> to decide between using Counter or using the new multiset/bag
> container for their algorithm?
>
> That's an open question, but at the very least, it's worth considering
> as an alternative to further elaborating on an already confusing
> aspect of the collections.Counter design. There's at least one such
> example of a bag API already available on PyPI:
> https://pypi.python.org/pypi/data-structures/0.1.4#bag (you need
> "-Counter" in a Google search to find that, as most current hits
> describe the use of Counter as a multiset, rather than using a
> dedicated container type)
I have also wondered about the feasibility of separating out the multiset features into a distinct type. Seems like
that would avoid a bunch of confusion.
--
~Ethan~
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20141123/5f0baa68/attachment.sig>
More information about the Python-ideas
mailing list