python
thread
process
profiling
python performance
asyncio
python 线程,GIL 和 ctypes
描述python的GIL歷史,三種 真多工 :sweat_smile: 解決方法
分別為:
multiprocessing — Process-based “threading” interface
以下只有python3才有支援
2.7:QQ
ThreadpoolExecutor
PeocessPoolExecutor
concurrent.futures
https://github.com/bfortuner/ml-study/blob/master/multitasking_python.ipynb
multiprocess:Should see good benefit
multithread:Should see good benefit
multithread:Should see good benefit
multiprocess:Should see good benefit
在IO下兩者在多tasks中都有良好的效果
multithread:yes,a little
multiprocess:yes, a little
numpy:very good
multithread:No benefit
multiprocess:No benefit
numpy function直接使用numpy的function會帶來更好的效果
multithread:No benefit
multiprocess:very good
CPU Intensive下的multiprocess表現較優
Pillow(The friendly PIL fork (Python Imaging Library))
multithread:good
multiprocess:good
https://github.com/python/asyncio/wiki/Benchmarks
https://docs.python.org/3/library/asyncio-task.html