I wrote a beautiful multi-threaded script, and when I ran it, it did worse with 25 threads than with a direct call to the thread handler.
Then I discovered a global interpreter lock. I want to ask, before I drop python for this script and rewrite the thing in something else, is there a way to make the actual multithreading work in python?
Another approach is to discard threads and instead use the Multiprocessing module (Python 2.6+), which bypasses the GIL, and has an API that is at least similar to the API in the stream module.
Now this is an interesting question - I don't think he escaped the GIL in direct CPython.
Stackless Python should improve concurrency performance compared to CPython using microthreads , but I don't think it eludes GIL.
Also, according to the GIL page on python.org , Jython and IronPython do not have a GIL.
, .
CPU ( IO-) , , , GIL , concurrency. , concurrency, , , Python.
, , .
CPython ( Python C) , . ( , , , , !).
You might want to be interested in IronPython (.NET) or JPython (Java / JWM). I have not used them, but I believe that at least one of them supports threads that are native to this runtime.
You can try the multiprocessing module , if applicable to your problem.
Source: https://habr.com/ru/post/1779045/More articles:Run the script on a specific date? - linuxHow Caliburn.Micro will cope with the ability to set breakpoints in Silverlight 5 - visual-studio-2010https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1779042/converting-mspec-tests-to-plain-nunit&usg=ALkJrhhoNN9Apqh0npMMLk9gP1BLnl7y8gFormatting dates in Freemarker to say Today, Yesterday, etc. - dateDateDiff window in SQL Server - sqlOracle 11g and database connection - javaCLLocationManger отправляет сообщение в dallocated instance - iphoneUsing Hadoop to Output Bucket Data with One Run - mapreduceHow do I cancel JSON in JavaScript? - jsonIOS app crashes in Core Location callback - iosAll Articles