Jul-24-2023, 09:10 PM
(This post was last modified: Jul-24-2023, 09:10 PM by deanhystad.)
The compiler does not change the order of instructions. "Compiling" in Python consists of converting the source code to bytecode that is run by the Python interpreter. There is no optimization stage that can change the order of the instructions. Loops remain loops. They are not flattened,
Python programs are single threaded unless they are explicitly written to be multi-threaded or use multiprocessing. You don't have to worry about the python interpreter taking your program and running it on multiple processors without your knowledge.
If you are doing multi-processing, there is no automatic mechanism for doing so. You have to write the code to create subprocesses. When using multiprocessing, there is no automatic method for synchronization. You have to write extra code to synchronize the processes. This can be fairly simple if you just need to wait for a subprocess to complete (start/join, await) but is more complicated when trying to synchronize two processes while running.
Could you provide more information about your particular concerns and what you are trying to do?
Python programs are single threaded unless they are explicitly written to be multi-threaded or use multiprocessing. You don't have to worry about the python interpreter taking your program and running it on multiple processors without your knowledge.
If you are doing multi-processing, there is no automatic mechanism for doing so. You have to write the code to create subprocesses. When using multiprocessing, there is no automatic method for synchronization. You have to write extra code to synchronize the processes. This can be fairly simple if you just need to wait for a subprocess to complete (start/join, await) but is more complicated when trying to synchronize two processes while running.
Could you provide more information about your particular concerns and what you are trying to do?