我有一个具有10个cpu核心的服务器,当我运行以下代码时,其中一个线程的cpu核心使用率是100%: while 1:但是当我使用5个线程运行相同的代码时,有5个cpu核心的使用分别是: 30%、20%、15%、25%、12%。如果多个python线程不能完全使用CPU,那么多线程应该比一个线程更快吗?
threadpool.add_task(task)
result = threadpool.complete_and_return_result()
编辑:从multithreading更改为multiprocessing后,性能如下所示。代码在20秒后完成,而使用multithreading则需要15分钟。
我有一些Cython代码,我想尽快运行。我需要释放吉尔才能这样做吗?function not allowed without gilnogilcode.pyx:7:27: Accessing Python global or builtin not allowed without gil
nogilcode.pyx:7:40: Constructi