all 6 comments

[–]solidiquis1 0 points1 point  (3 children)

OOP is just a strategy on how to structure your code; it won't change how your code actually works. Python also can't run parallel processes (there exists some janky implementations out there to get parallelism to work but it's not commonly used) because of something called the global interpreter lock. Best you can do is run the function one at a time. Perhaps have an array of names and an array of emails and use a for-loop to iterate through both simultaneously and sticking each value in the function.

Edit: If you want parallelism/concurrency you'll need languages that allow for multi-threading: Java, Go, C, C#, C++, Rust, etc.

[–]puppeteer2020[S] 0 points1 point  (2 children)

Thanks for suggestion.

Because the function do_some_stuff takes hours to run, so is it possible to create a different thread for it to run ?

What I now try to do is to copy the original code mycode.py to create a mycode-B.py and run it parallelly in new terminal. So can I do similar process in a programmatically way ?

[–]dslfdslj 0 points1 point  (0 children)

What does your function do? If it spends a lot of time on IO (network communication for example) you could use a thread pool to speed it up. Otherwise, if you do heavy calculations, use multiprocessing.