On 1/15/2020 7:43 PM, Kyle Stanley wrote:
> I suggest that when you need this functionality you create your own data
> structure combining a list and a collections.Counter and keep track of
> this yourself.

I concur with the usage of collections.Counter here. Storing the count for every single item in a list could end up being rather redundant with duplicate elements, so Counter ends up being much more space efficient. With it being implemented as a dictionary, the lookup speeds are incredibly quick for getting an on-demand count for any item within it.

But, is it practically beneficial to combine the functionality of a list and collections.Counter instead of just using both data structures together?

I meant by composing them in another class, which could then have whatever interface makes sense for this data structure.

Eric
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/XWHTPRUSCDXO2H2ZMLGKS24AVAYTSLQX/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to