> I meant by composing them in another class, which could then have > whatever interface makes sense for this data structure.
Ah, I see. I had misunderstood you and thought you were advising the OP to combine list and Counter into their own new data structure, which seemed a bit overkill. That makes a lot more sense, thanks for the clarification. On Wed, Jan 15, 2020 at 8:20 PM Eric V. Smith <[email protected]> wrote: > 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 -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/3THZZAFKUFB4FQGKDHYYXAFEKE5GLABW/ Code of Conduct: http://python.org/psf/codeofconduct/
