Why does my Python program average only 33% CPU per process? How can I make Python use all available CPU?

后端 未结 7 1845
难免孤独
难免孤独 2021-02-01 08:11

I use Python 2.5.4. My computer: CPU AMD Phenom X3 720BE, Mainboard 780G, 4GB RAM, Windows 7 32 bit.

I use Python threading but can not make every python.exe process co

7条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-01 09:06

    Try the multiprocessing module, as Python, while it has real, native threads, will restrict their concurrent use while the GIL is held. Another alternative, and something you should look at if you need real speed, is writing a C extension module and calling functions in it from Python. You can release the GIL in those C functions.

    Also see David Beazley's Mindblowing GIL.

提交回复
热议问题