[英]What is the time complexity of collections.Counter() in Python?
[英]What's the time complexity of Python's collections.Counter.total()?
Python 的 collections.Counter.total() 的时间复杂度是多少? 我已经阅读了该方法的文档,但没有提到它的效率。 有谁知道该方法是如何在后台实现的以及它的时间复杂度是多少?
在 CPython 中,它看起来像是使用sum(self.values())
实现了total()
) ,所以它是O(number of values in the Counter)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.