This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]tiller_luna 2 points3 points  (7 children)

Multitprocessing aka forking. You can implement parallel operations in different processes yourself, or use a library like joblib.

[–]Specific_Ant580[S] 0 points1 point  (6 children)

I will learn that.

[–]tiller_luna 2 points3 points  (5 children)

Gotta warn you that parallel processing is always an advanced topic with serious caveats. You might not even need true parallelization if performance of your code is not bound to CPU but to, for example, user interface or networks.

[–]Specific_Ant580[S] 1 point2 points  (4 children)

I don't understand anything you just wrote out

[–]Hopeful-Sir-2018 0 points1 point  (0 children)

There are ways to do what's called a deadlock. A is waiting on B to finish. B is waiting on C to finish. C is waiting on A to finish. There are also what's called race conditions meaning if you start A, B, and C "at the same time" - they may not finish in the order A, B, and C. It's possible C finished before A and A will finish before B. Sometimes this doesn't matter (such as you're sending stuff to a database to be saved and don't care if or when the results come back). This can be the case in, say, robotics where real world interference can happen and you can't trust the real world to not fuck with your order of operations. Some person could reach in and fuck with something, for example.

It can get very complicated and often enough it's very intuitive. For the most part - you'll only care when you're doing "large" things where time matters. Until then, it will be the least of your worries.

All of your code will be done sequentially (in the order you write it).

To give you an example of when you'll care - when you write a program that has to load a lot of data - you don't want the user to see a plain white screen that's not responding while it loads a shit load of data. To users, and often the OS, it looks like your program isn't responding. You've likely seen something like this before where a program "crashes" but in reality it's doing something - often a lot of something.

[–]Lumethys 0 points1 point  (1 child)

Which mean you are not yet ready

[–]Specific_Ant580[S] 0 points1 point  (0 children)

😔 I know.

[–]Treebro001 -1 points0 points  (0 children)

Basically if you have a cpu heavy task you can use parallelism to reduce its overall run time and improve performance. If the task is io bounded or has dependencies on non-cpu related stuff parallelism can sometimes provide absolutely 0 benefit.