久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <small id='fcuBy'></small><noframes id='fcuBy'>

      <bdo id='fcuBy'></bdo><ul id='fcuBy'></ul>
    <i id='fcuBy'><tr id='fcuBy'><dt id='fcuBy'><q id='fcuBy'><span id='fcuBy'><b id='fcuBy'><form id='fcuBy'><ins id='fcuBy'></ins><ul id='fcuBy'></ul><sub id='fcuBy'></sub></form><legend id='fcuBy'></legend><bdo id='fcuBy'><pre id='fcuBy'><center id='fcuBy'></center></pre></bdo></b><th id='fcuBy'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='fcuBy'><tfoot id='fcuBy'></tfoot><dl id='fcuBy'><fieldset id='fcuBy'></fieldset></dl></div>
  • <legend id='fcuBy'><style id='fcuBy'><dir id='fcuBy'><q id='fcuBy'></q></dir></style></legend>

      1. <tfoot id='fcuBy'></tfoot>

        為什么 numpy 計算不受全局解釋器鎖的影響?

        Why are numpy calculations not affected by the global interpreter lock?(為什么 numpy 計算不受全局解釋器鎖的影響?)
        <legend id='CZWIN'><style id='CZWIN'><dir id='CZWIN'><q id='CZWIN'></q></dir></style></legend>
          <bdo id='CZWIN'></bdo><ul id='CZWIN'></ul>
            <tbody id='CZWIN'></tbody>

            <small id='CZWIN'></small><noframes id='CZWIN'>

            • <tfoot id='CZWIN'></tfoot>

                <i id='CZWIN'><tr id='CZWIN'><dt id='CZWIN'><q id='CZWIN'><span id='CZWIN'><b id='CZWIN'><form id='CZWIN'><ins id='CZWIN'></ins><ul id='CZWIN'></ul><sub id='CZWIN'></sub></form><legend id='CZWIN'></legend><bdo id='CZWIN'><pre id='CZWIN'><center id='CZWIN'></center></pre></bdo></b><th id='CZWIN'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='CZWIN'><tfoot id='CZWIN'></tfoot><dl id='CZWIN'><fieldset id='CZWIN'></fieldset></dl></div>

                • 本文介紹了為什么 numpy 計算不受全局解釋器鎖的影響?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我正在嘗試決定是否應該使用多處理或線程,并且我學到了一些關于 全局解釋器鎖.在這篇不錯的博文中,似乎多線程不適合繁忙的任務.但是,我也了解到某些功能,例如 I/O 或 numpy,不受 GIL 的影響.

                  I'm trying to decide if I should use multiprocessing or threading, and I've learned some interesting bits about the Global Interpreter Lock. In this nice blog post, it seems multithreading isn't suitable for busy tasks. However, I also learned that some functionality, such as I/O or numpy, is unaffected by the GIL.

                  誰能解釋一下原因,以及我如何確定我的(可能是相當 numpy-heavy)代碼是否適合多線程?

                  Can anyone explain why, and how I can find out if my (probably quite numpy-heavy) code is going to be suitable for multithreading?

                  推薦答案

                  許多 numpy 計算不受 GIL 影響,但不是全部.

                  Many numpy calculations are unaffected by the GIL, but not all.

                  在不需要 Python 解釋器的代碼(例如 C 庫)中,可以專門釋放 GIL - 允許依賴于解釋器的其他代碼繼續運行.在 Numpy C 代碼庫中,宏 NPY_BEGIN_THREADSNPY_END_THREADS 用于分隔允許 GIL 發布的代碼塊.你可以在 這個 numpy 源的搜索中看到這些.

                  While in code that does not require the Python interpreter (e.g. C libraries) it is possible to specifically release the GIL - allowing other code that depends on the interpreter to continue running. In the Numpy C codebase the macros NPY_BEGIN_THREADS and NPY_END_THREADS are used to delimit blocks of code that permit GIL release. You can see these in this search of the numpy source.

                  NumPy C API 文檔 有更多關于線程支持的信息.注意處理條件 GIL 釋放的附加宏 NPY_BEGIN_THREADS_DESCRNPY_END_THREADS_DESCRNPY_BEGIN_THREADS_THRESHOLDED,取決于數組 dtypes 和大小的循環.

                  The NumPy C API documentation has more information on threading support. Note the additional macros NPY_BEGIN_THREADS_DESCR, NPY_END_THREADS_DESCR and NPY_BEGIN_THREADS_THRESHOLDED which handle conditional GIL release, dependent on array dtypes and the size of loops.

                  大多數核心函數都發布了 GIL - 例如 通用函數 (ufunc) 這樣做 如所述:

                  Most core functions release the GIL - for example Universal Functions (ufunc) do so as described:

                  只要不涉及對象數組,Python 全局解釋器鎖 (GIL) 就會在調用循環之前釋放.必要時重新獲取它以處理錯誤情況.

                  as long as no object arrays are involved, the Python Global Interpreter Lock (GIL) is released prior to calling the loops. It is re-acquired if necessary to handle error conditions.

                  關于您自己的代碼,NumPy 的源代碼可用.檢查您為上述宏使用的函數(以及它們調用的函數).另請注意,性能優勢在很大程度上取決于多長時間 GIL 發布 - 如果您的代碼不斷地加入/退出 Python,您將不會看到太大的改進.

                  With regard to your own code, the source code for NumPy is available. Check the functions you use (and the functions they call) for the above macros. Note also that the performance benefit is heavily dependent on how long the GIL is released - if your code is constantly dropping in/out of Python you won't see much of an improvement.

                  另一種選擇是測試它.但是,請記住,使用條件 GIL 宏的函數可能會針對小型和大型數組表現出不同的行為.因此,使用小數據集的測試可能無法準確表示大型任務的性能.

                  The other option is to just test it. However, bear in mind that functions using the conditional GIL macros may exhibit different behaviour with small and large arrays. A test with a small dataset may therefore not be an accurate representation of performance for a larger task.

                  官方 wiki 上提供了一些關于使用 numpy 進行并行處理的附加信息 以及一篇關于 Python GIL 的有用帖子在 Programmers.SE 上.

                  There is some additional information on parallel processing with numpy available on the official wiki and a useful post about the Python GIL in general over on Programmers.SE.

                  這篇關于為什么 numpy 計算不受全局解釋器鎖的影響?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  What exactly is Python multiprocessing Module#39;s .join() Method Doing?(Python 多處理模塊的 .join() 方法到底在做什么?)
                  Passing multiple parameters to pool.map() function in Python(在 Python 中將多個參數傳遞給 pool.map() 函數)
                  multiprocessing.pool.MaybeEncodingError: #39;TypeError(quot;cannot serialize #39;_io.BufferedReader#39; objectquot;,)#39;(multiprocessing.pool.MaybeEncodingError: TypeError(cannot serialize _io.BufferedReader object,)) - IT屋-程序員軟件開
                  Python Multiprocess Pool. How to exit the script when one of the worker process determines no more work needs to be done?(Python 多進程池.當其中一個工作進程確定不再需要完成工作時,如何退出腳本?) - IT屋-程序員
                  How do you pass a Queue reference to a function managed by pool.map_async()?(如何將隊列引用傳遞給 pool.map_async() 管理的函數?)
                  yet another confusion with multiprocessing error, #39;module#39; object has no attribute #39;f#39;(與多處理錯誤的另一個混淆,“模塊對象沒有屬性“f)
                • <legend id='pSe3H'><style id='pSe3H'><dir id='pSe3H'><q id='pSe3H'></q></dir></style></legend>

                        <tbody id='pSe3H'></tbody>

                        <bdo id='pSe3H'></bdo><ul id='pSe3H'></ul>
                        <tfoot id='pSe3H'></tfoot>
                            <i id='pSe3H'><tr id='pSe3H'><dt id='pSe3H'><q id='pSe3H'><span id='pSe3H'><b id='pSe3H'><form id='pSe3H'><ins id='pSe3H'></ins><ul id='pSe3H'></ul><sub id='pSe3H'></sub></form><legend id='pSe3H'></legend><bdo id='pSe3H'><pre id='pSe3H'><center id='pSe3H'></center></pre></bdo></b><th id='pSe3H'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='pSe3H'><tfoot id='pSe3H'></tfoot><dl id='pSe3H'><fieldset id='pSe3H'></fieldset></dl></div>
                          • <small id='pSe3H'></small><noframes id='pSe3H'>

                          • 主站蜘蛛池模板: 青青国产 | 日韩黄色免费视频 | 日韩二区三区 | 黄色大片免费在线观看 | 秋霞午夜鲁丝一区二区老狼 | 一级片免费在线观看 | 国产精品免费一区二区三区 | 免费视频一区 | 成人综合婷婷国产精品久久 | 超碰免费公开 | 久久综合五月天 | 天天做天天操 | 国产欧美日韩在线观看 | 亚洲黄色在线观看 | 国产h视频在线观看 | 亚洲蜜桃av | 成人免费看片在线观看 | 免费看毛片网站 | 亚洲精品www久久久久久广东 | 欧美一级特黄aa大片 | 免费毛片网站 | 在线观看日韩视频 | 波多野吉衣一二三区乱码 | 欧美在线视频一区 | 综合网av| 日韩视频一区二区 | 国产黄a三级三级三级看三级男男 | www黄色| 97在线免费观看视频 | 日韩欧美一区二区三区 | 黄色在线免费看 | 一区二区国产精品 | 国产又粗又猛又黄又爽的视频 | 人人澡人人干 | 久久精品在线播放 | 中文字幕自拍偷拍 | 欧美精品在线视频 | 超碰在线观看免费版 | 国产伦精品一区二区三区88av | www.97超碰| 成年人视频在线播放 |