Hi Sylvian,
As far as I understand, the In-process execution has the following advantages over Out-of-process execution mode:
- The memory and computation overhead is less
- There is no limitation on size of variables as mentioned in the MATLAB documentation (linked below)
The Out-of-process execution mode enables you to execute your Python functions or script as a standalone process separate from the MATLAB processes.
This means that you will have the following advantages while running your Python code Out-of-process:
- You can use third party library and tools which could potentially interfere with MATLAB
- You are isolating your python code and MATLAB code which means your MATLAB apps will not affected from the crashes caused by the Python code
Its disadvantages when compared to In-process execution would be,
- Larger memory and processing overhead because new processes are created to run the Python code. This could affect performance.
- When using Out-of-process execution mode, maximum of 2GB data can be passed between the Python process and MATLAB at a time. This means your variables are limited to be under 2GB if you want to pass them to MATLAB.
Disadvantages of In-Process execution when compared to Out-of-process execution would be,
- If you need to change the class definitions once you have started the In-process execution, you will need to restart your MATLAB session.
- Any crashes in the Python code will affect MATLAB apps and may cause them to crash.
- You will not be able to use third party libraries and tools that conflict with MATLAB.
In an nutshell, In-process execution is preferable if you want to use some small Python functions or scripts in MATLAB while if you need to use heavier Python workflows possibly involving lot of third party tools or libraries then Out-of-process execution mode would be more suitable for you.
You may refer to the MATLAB documentation for more details. Consider following these links to get started:
Hope this resolves the doubt!