Answer the question
In order to leave comments, you need to log in
Which is better - multithreading or parallelism (Python)?
Which approach to writing a project is more preferable - parallel or multi-threaded in the context of Python? input Output. What exactly is a task? I am writing a project in Python that uploads data, everything depends on several tens of thousands of requests in 5-6 hours. I lean more towards the parallel way than the multithreaded way (hello GIL). I need advice from an expert with experience in this. Have I correctly defined for myself the way to implement the task, or did I miss it all the same? Thanks in advance
Libraries:
Multiprocessing
Threading
Answer the question
In order to leave comments, you need to log in
asyncio has a convenient mechanism for running a task asynchronously in a separate process via run_in_executor() , so it's not such a hard choice.
Multiprocessing is faster, but there are problems with passing complex objects. In fact, only primitives, dictionaries, and lists can be passed back and forth. Things like numpy arrays have to be converted.
So if that's not a problem, multiprocessing rules.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question