python - How do I create an array of 3D coordinates in Python?
问题描述
I was wondering what would be an efficient way to create an array of coordinates of a 3d space. For example:
[ [x,y,z] ,for x in range(1000) for y in range(1000) for z in range(1000) ]
will take allot of time.
解决方案
您可以使用 Numpy 和 mgrid 函数:https ://docs.scipy.org/doc/numpy/reference/generated/numpy.mgrid.html
但主要问题是您分配了大量内存,这总是很慢。也许您可以编写具有较小分辨率的程序并一次执行 10 步?
推荐阅读
- database - 从小部件内返回未来的函数获取值
- azure - 将所有 AKS 微服务通过管道传输到单个 Application Insights 中,并能够按微服务名称进行筛选
- java - 自定义类的 ArrayList 未正确保存到文件中?
- postgresql - Postgres:你还在用 SSD 分离数据和索引吗
- xaml - 如何为 xaml 控件创建一个通用的超类?
- c++ - cpp 中定义的模板方法的 std::enable_if
- python - Python 在文件中查找特定行并在其下方追加
- java - 如何在 DynamoDB 上使用 DATE_PART(MONTH, month)?
- python - 在 Tensorflow 2.0 中记录到 tensorboard 的内部损失函数
- .htaccess - htaccess 重定向来自多个子域的链接