NeoTheThird NeoTheThird - 11 months ago 51
Python Question

Does executing a python script load it into memory?

I'm running a python script using

on Ubuntu 16.04. Is the script loaded into memory or read and interpreted line by line from the hdd? If it's not loaded all at once, is there any way of knowing or controlling how big the chunks are, that are loaded into Memory?

Answer Source

It is loaded into memory in its entirety. This must be the case, because a syntax error near the end will abort the program straight away. Try it and see.

There does not need to be any way to control or configure this. It is surely an implementation detail best left alone. If you have a problem related to this (e.g. your script is larger than your RAM), it can be solved some other way.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download