On Tue, Jan 14, 2020 at 10:03:24PM -0600, Hunter Jones wrote:
> Hey everyone,
> 
> I recently used list.count() in a coding interview and the question arose
> about how scale-able this solution was for sufficiently large input.
> Currently, list.count iterates through the list, incrementing the count as
> it goes and returning the value at the end. This does not lend itself well
> to large inputs.
> 
> I propose either modifying the list struct to include a map of item ->
> count, or implementing a new structure with this information that is
> allocated separately when a list is instantiated.
> 
> Maybe I'm just seeing this since it's an edge case that I recently dealt
> with, but I believe it would be a useful enhancement overall.
> 
> Thoughts?

Hi Hunter,

does collections.Counter meet your needs?

https://docs.python.org/3.8/library/collections.html#collections.Counter

best,
--titus
-- 
C. Titus Brown, ctbr...@ucdavis.edu
_______________________________________________
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/D4GW3BTZCMI472BTH66WPA6I4HSHALN5/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to