G
G
GreenX52021-10-05 12:25:58
Python
GreenX5, 2021-10-05 12:25:58

Is importing Python modules loading into RAM?

I am writing a server in python, acc. the code will import third-party modules. They are accessed periodically from the infinite loop of the main thread.
Once a minute there will be reading and writing to files, access to module functions.
The server is a laptop (the solution to the issue of backup power), I will put at least 32 RAM
. Actually, the struggle for the speed of the code and the life of the SSD.
I do not know for sure - modules are imported into RAM or only paths, respectively. in case of multiple repeated calls to module functions, they are taken from the installation site (disk) each time, or the scavenger does not sweep them out of RAM after the next function completion.
So, does it make sense to put on RAMDISK:
1. modules
2. all Python
3. other methods?

Friends, I ask you to answer with knowledge of the question, conjectures, and I myself have plenty. Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Karbivnichy, 2021-10-05
@GreenX5

A RAM disk is not needed here. If you need speed - you need the appropriate processor. An SSD (if it's not made 50 years ago) will outlive a laptop.
I myself parsed 1 million html files in Python - both on SSD and from RAM. There was absolutely no time difference.

R
Ronald McDonald, 2021-10-05
@Zoominger

The OS handles loading to RAM or storing to swap.
Usually loads directly into RAM.
RAMdisk is a cool idea, throw everything there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question