How can I efficiently read and write files that are too large to fit in memory?

后端 未结 2 2023
北荒
北荒 2021-02-12 15:37

I am trying to calculate the cosine similarity of 100,000 vectors, and each of these vectors has 200,000 dimensions.

From reading other questions I know that memmap, PyT

2条回答
  •  情书的邮戳
    2021-02-12 15:41

    Memory maps are exactly what the name says: mappings of (virtual) disk sectors into memory pages. The memory is managed by the operating system on demand. If there is enough memory, the system keeps parts of the files in memory, maybe filling up the whole memory, if there is not enough left, the system may discard pages read from file or may swap them into swap space. Normally you can rely on the OS is as efficient as possible.

提交回复
热议问题