简体   繁体   English

将临时数据存储在数组中还是将其保存到文件中以供以后访问是否更好?

[英]Is it better to store temp data in arrays or save it to file for access later?

This is a broad question. 这是一个广泛的问题。 I am running a very long simulation (in Python) that generates a sizeable amount of data (about 10,000 729*729 matrices). 我正在运行一个很长的模拟(在Python中),该模拟会生成大量数据(大约10,000 729 * 729矩阵)。 I only need the data to plot a couple of graphs and then I'm done with it. 我只需要数据就可以绘制几个图,然后就完成了。 At the moment I save the data in (numpy) arrays. 目前,我将数据保存在(numpy)数组中。 When the simulation is complete I plot the data. 模拟完成后,我将绘制数据。

One alternative would be to write the data to a file, and then access the file after simulation to plot graphs etc. 一种替代方法是将数据写入文件,然后在仿真后访问该文件以绘制图形等。

In general is there consensus on the best (ie quickest) way to manage large temporary data sets. 通常,对于管理大型临时数据集的最佳(即最快)方法已达成共识。 Is either of these "best practice"? 这些“最佳实践”中的任何一个?

Try to make the data obsolete as fast as possible by further processing/accumulating eg plotting immediately. 尝试通过进一步处理/累积(例如立即绘制)来使数据尽可能快地过时。

You did not give details about the memory/storage needed. 您没有提供有关所需内存的详细信息。 for sparse matrices there are efficient representations. 对于稀疏矩阵,存在有效的表示。 if your matrices are not sparse there are roughly 500k entries per matrix and therefore 5G entries altogether. 如果矩阵不稀疏,则每个矩阵大约有500k条目,因此总共有5G条目。 without knowing your data type this could be typically 40GB of memory. 不知道您的数据类型,通常可能是40GB的内存。

I strongly suggest to review your algorithms for achieving a smaller memory footprint. 我强烈建议您查看算法以减少内存占用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将用户输入数据保存在 kivy 中并存储以供以后使用/分析 python - save user input data in kivy and store for later use/analysis python 如何将 model.state_dict() 存储在临时变量中以备后用? - how to store model.state_dict() in a temp var for later use? 如何从帧的 ndarray 访问单个像素阵列,或者是否有更好的方法来存储帧并访问它们? - How can I access the individual pixel arrays from an ndarray of frames or is there a better way to store the frames and access them? 将字典存储在文件中以供以后检索 - Store a dictionary in a file for later retrieval 存储绘制的数据供以后使用 - Store plotted data for later use 如何从 .csv 网络文件中提取数据并存储到变量中,并可以选择稍后将其存储在数据库中 - how to pul data from a .csv web file and store to a variable with the option to store it later in a database 将多个图存储在列表中以便以后访问它们 - store several plots in a list to access them later 无法找到一种方法来存储这些抓取的数据,以便我以后可以在一个简单的循环的帮助下访问它? - Unable to find a way to store this scraped data in such a way that i can access it later with the help of a simple loop? 用数组存储一组文件的更好方法? - Better way to store a set of files with arrays? 如何在python的数据文件中将数组作为列元素写入并稍后在C中读取? - How to write arrays as column elements in a Data file in python and read it later in C?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM