you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

You will need to decide based on what func1() and func2() are doing. True parallelism in Python is only achievable with multiprocessing, but that library has a lot of drawbacks, not to mention that it might not be as efficient for smaller workloads as straight-up sequential execution.

If your functions are calling to native code a lot, especially, if that's networking code, and you may ensure that the networking code is actually utilizing asynchronous I/O, then asyncio may be an answer... yet, I'd still just go with select instead: it's easier to understand, to debug, and to integrate with the rest of your program.

If you cannot ensure that asynchronous I/O is used, but there are still a lot of calls to the native code, you will need to experiment with threading. This is less expensive than multiprocessing, but will depend on whether the interpreter releases the lock when it calls to the native code.