len()函数的成本 [英] Cost of len() function
本文介绍了len()函数的成本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
len()
函数的Python内置函数? (list / tuple / string / dictionary)
What is the cost of len()
function for Python built-ins? (list/tuple/string/dictionary)
推荐答案
这是 O(1)对于您提到的每种类型,加上 set
和其他如 array.array
。
It's O(1) (very fast) on every type you've mentioned, plus set
and others such as array.array
.
这篇关于len()函数的成本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文