I have a program written in Fortran and compiled (with -fPIC) as a dynamic library. I load with CDLL in Python to perform some numerical calculations. The library uses internal persistent memory (in modules) to save intermediate values. I work both on Windows and Linux (with a .dll and an .so, respectively). The dynamic library is packaged inside the Python module and installed in a lib subdirectory.
If I run two different Python scripts that load the dynamic library on the same computer, would they get a separate internal memory or will they access the same one (thus, corrupting the results)?
How would this be affected if I:
- Load them inside a different multiprocessing instance
- Load them inside a different multithreading instance
- Load them in two different Jupyter notebooks with different kernel
- Run them in different Python virtual environments
There is a similar question. However, since the dynamic library is included in the Python module, I want to avoid having to rename and move around files.