我突然想到我不知道如何将原始数值写入磁盘。 我如何在 Python 或 C++ 中执行此操作?!
我正在运行一些模拟并将中间结果写入磁盘,以便它在崩溃时不会从头开始。 遗憾的是,这些值在我的硬盘驱动器上占用了千兆字节的空间。
将数值写入磁盘作为 float 会占用更少的磁盘空间,还是有一些我没有考虑的其他开销?
最佳答案
最通用和最强大的选项是使用 HDF5 format , 在 Python interface 的帮助下.来自网站:
It lets you store huge amounts of numerical data, and easily manipulate that data from NumPy. For example, you can slice into multi-terabyte datasets stored on disk, as if they were real NumPy arrays. Thousands of datasets can be stored in a single file, categorized and tagged however you want
它还有一个 C++ API .
HDF5 格式广泛用于科学计算界,并被许多软件读取/写入。使用 parallel utility tools 可以快速处理 HDF5 格式的数据.
关于python - 将原始数字写入磁盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25586192/