簡體   English   中英

Python 的 collections.Counter.total() 的時間復雜度是多少?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM