釋義GIL:Global Interpreter Lock
基于GIL的原因,同一時(shí)刻只有一個(gè)線(xiàn)程能執(zhí)行python代碼(即使某些性能導(dǎo)向的庫(kù)能克服這個(gè)限制)
CPython implementation detail:?In CPython, due to the?Global Interpreter Lock, only one thread can execute Python code at once (even though certain performance-oriented libraries might overcome this limitation). If you want your application to make better use of the computational resources of multi-core machines, you are advised to use?multiprocessing?or?concurrent.futures.ProcessPoolExecutor. However, threading is still an appropriate model if you want to run multiple I/O-bound tasks simultaneously.
來(lái)源:threading — Thread-based parallelism — Python 3.10.0 documentation