【发布时间】:2011-08-20 07:08:50
【问题描述】:
我指的是这个:http://docs.python.org/tutorial/datastructures.html
就大 O 表示法而言,list.index(x) 函数的运行时间是多少?
【问题讨论】:
-
可以找到索引操作的源代码here。是
O(n)。 -
它比我预期的要快得多。
%%timeit说 2.2ns 而通过 ORM(暖查询集)获取属性是 80ns。
标签: python algorithm list big-o performance