好吧,我弄错了,concurrent与multiprocessing与只有在处理IO型任务的时候才有优势,计算型任务没有什么不同。
伊谢尔伦2017-04-18 10:12:22
Are you sure the code is correct? Why do you feel that multiprocess calculates it twice...
PHP中文网2017-04-18 10:12:22
Multi-process is among multiple processes, the blocking of one process will not affect other processes. For example, performing a large number of calculation operations in one process will not have a major impact on other processes.
Coroutine is in a thread. If one task in the coroutine is blocked, other tasks will also be affected. For example, if a large number of calculation operations are performed in a task, this task will block other tasks.
So coroutines are not suitable for processing computing-intensive tasks, but are suitable for processing IO-intensive tasks. Because Ctrip cooperates with asynchronous IO, you can get the pleasure of synchronous programming without blocking the process.