如果您只是操作二进制值序列,您会使用 numpy 吗?
当您对二进制值列表进行大量操作时,使用 numpy 有什么优势吗?小范围内的整数怎么样(比如数字 1,2 和 3?)
Is there any advantage to using numpy when you're doing a large number of operations on lists of binary values? How about integers within a small range (like just the numbers 1,2, and 3?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
消除循环是性能提升 (10 倍) 的来源:
numpy:
秒
列表:
秒
Eliminating the loops is the the source of the performance gain (10x):
numpy:
seconds
lists:
seconds
如果输入值的数量很大,或者您正在进行大量操作,您可能需要尝试 位数组。或者,查看 Numpy 的 ndarray 中的
bool
/int8
/uint8
dtype:If the number of input values is huge, or if you are doing a lot of operations, you might want to try bitarray. Or, see the
bool
/int8
/uint8
dtype in Numpy's ndarray: