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?
CodePudding user response:
In CPython, it looks like it implements total()
using sum(self.values())
, so it's O(number of values in the Counter)
.