python - 迭代切片数组的计算效果
问题描述
如果我取一个切片的切片......一个numpy数组,我是在创建一个深度嵌套的数据结构吗?
我要问的概述:
data = np.rand(1024)
while more_to_do(data):
removed_value = select_item(data)
# use slicing to "remove" a particular value from the array
data = data[data!=removed_value]
# Another way to ask the question, would be
# does indexing into data after taking
# all of these slices, e.g. calling
value = data[5]
# take time proportional to the number of iterations
# through the loop?
实际上下文是在凹壳算法的特定实现中,该算法使用这种切片迭代地从考虑中删除点,因为它们被选为壳的一部分。
解决方案
推荐阅读
- linux - 在 C 程序中调用 pppd 会阻塞线程
- javascript - JavaScript 为页面上的所有 Web 部件分配颜色
- woocommerce - 如何隐藏某个品类单品页面的SKU?
- javascript - 我的 Angular Universal SPA 消耗大量内存。如何识别内存泄漏的位置?
- c# - 按住鼠标按钮时充电并释放它
- r - 在r中生成不同长度的随机数,然后组合
- mongodb - express/mongo 可以推送新数据,但无法更新现有数据
- python - Keras ValueError: Error when checking model target (CNN)
- python - 如何有效地将数据从 Postgres 传输到 Amazon Redshift?
- c++ - 删除后内存泄漏[]