What's the time complexity of Python's collections.Counter.total()? I've read the documentation for the method, but there's not mention of its efficiency. Does anyone know how the method is implemented under the hood and what its time complexity is?
Asked
Active
Viewed 343 times
0
-
3There are many implementations of Python. – Peter Wood Dec 02 '21 at 23:45
-
Almost certainly it is linear, although I suppose the total could be calculated each time the dict is modified and then the method just retrieves this total, but I doubt it – juanpa.arrivillaga Dec 02 '21 at 23:51