[Python-Dev] Candidate Itertools

Chermside, Michael mchermside at ingdirect.com
Thu Jun 17 07:52:44 EDT 2004


[Michael Chermside]
> Is the behavior of count_elements() exactly the same as
> the given python equivalent when one (or more) of the
> elements in the iterable is not hashable?

[Raymond Hettinger]
> That was the original idea; however, we could easily keep a separate
> list of identity comparisons for unhashables

If you do indeed handle unhashables, then I think this interface
seems useful, although I'd order it (elem, cnt) so that when
everything IS hashable a dict can be built via
    dict(*count_elements(iterable))
If you do NOT handle unhashables, then I'd agree with Bob that
we should just return the dict itself -- that's the most natural
data structure for expressing a bunch of counts available in
Python. And I think the function is worth including.

-- Michael Chermside


This email may contain confidential or privileged information. If you believe you have received the message in error, please notify the sender and delete the message without copying or disclosing it.




More information about the Python-Dev mailing list