【发布时间】:2010-11-09 18:25:01
【问题描述】:
我想到了以下有关计算机体系结构的问题。假设我用 Python 做
from bisect import bisect
index = bisect(x, a) # O(log n) (also, shouldn't it be a standard list function?)
x.insert(index, a) # O(1) + memcpy()
这需要log n,另外,如果我理解正确的话,还有x[index:] 的内存复制操作。现在我最近读到瓶颈通常在于处理器和内存之间的通信,因此内存复制可以由 RAM 非常快地完成。是这样的吗?
【问题讨论】:
标签: python architecture memory list memcpy