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

        <bdo id='rfhmE'></bdo><ul id='rfhmE'></ul>
      <legend id='rfhmE'><style id='rfhmE'><dir id='rfhmE'><q id='rfhmE'></q></dir></style></legend>
    1. <tfoot id='rfhmE'></tfoot>

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

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

        為什么多處理中的新對象具有相同的 id?

        Why do new objects in multiprocessing have the same id?(為什么多處理中的新對象具有相同的 id?)
            • <legend id='g7A36'><style id='g7A36'><dir id='g7A36'><q id='g7A36'></q></dir></style></legend>
            • <small id='g7A36'></small><noframes id='g7A36'>

              <tfoot id='g7A36'></tfoot>

                • <bdo id='g7A36'></bdo><ul id='g7A36'></ul>
                    <tbody id='g7A36'></tbody>
                  <i id='g7A36'><tr id='g7A36'><dt id='g7A36'><q id='g7A36'><span id='g7A36'><b id='g7A36'><form id='g7A36'><ins id='g7A36'></ins><ul id='g7A36'></ul><sub id='g7A36'></sub></form><legend id='g7A36'></legend><bdo id='g7A36'><pre id='g7A36'><center id='g7A36'></center></pre></bdo></b><th id='g7A36'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='g7A36'><tfoot id='g7A36'></tfoot><dl id='g7A36'><fieldset id='g7A36'></fieldset></dl></div>
                  本文介紹了為什么多處理中的新對象具有相同的 id?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我嘗試在使用多處理模塊時在進程中創建新對象.但是,有些事情讓我感到困惑.

                  I tried to create a new object in a process when using multiprocessing module. However, something confuses me.

                  當我使用多處理模塊時,新對象的id是一樣的

                  When I use multiprocessing module, the id of the new object is the same

                  for i in range(4):
                      p = multiprocessing.Process(target=worker)
                      p.start()
                  
                  def worker():
                      # stanford named entity tagger
                      st = StanfordNERTagger(model_path,stanford_ner_path)
                      print id(st)    # all the processes print the same id
                  

                  但是當我使用線程時,它們是不同的:

                  But when I use threading, they are different:

                  for i in range(4):
                      p = threading.Thread(target=worker)
                      p.start()
                  
                  def worker():
                      # stanford named entity tagger
                      st = StanfordNERTagger(model_path,stanford_ner_path)
                      print id(st)    # threads print differnt ids
                  

                  我想知道為什么它們不同.

                  I am wondering why they are different.

                  推薦答案

                  idCPython 中的 返回給定對象的指針.由于線程共享地址空間,一個對象的兩個不同實例將被分配在兩個不同的位置,返回兩個不同的 id(也稱為虛擬地址指針).

                  id in CPython returns the pointer of the given object. As threads have shared address space, two different instances of an object will be allocated in two different locations returning two different ids (aka virtual address pointers).

                  對于擁有自己地址空間的獨立進程來說,情況并非如此.碰巧他們得到了相同的地址指針.

                  This is not the case for separate processes which own their own address space. By chance, they happen to get the same address pointer.

                  請記住,地址指針是虛擬的,因此它們表示進程地址空間本身的偏移量.這就是為什么它們是相同的.

                  Keep in mind that address pointers are virtual, therefore they represent an offset within the process address space itself. That's why they are the same.

                  通常最好不要依賴 id() 來區分對象,因為新對象可能會得到舊對象的 id,隨著時間的推移很難跟蹤它們.它通常會導致棘手的錯誤.

                  It is usually better not to rely on id() for distinguishing objects, as new ones might get ids of old ones making hard to track them over time. It usually leads to tricky bugs.

                  這篇關于為什么多處理中的新對象具有相同的 id?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)
                    • <bdo id='uWzhH'></bdo><ul id='uWzhH'></ul>
                          <tbody id='uWzhH'></tbody>
                        <i id='uWzhH'><tr id='uWzhH'><dt id='uWzhH'><q id='uWzhH'><span id='uWzhH'><b id='uWzhH'><form id='uWzhH'><ins id='uWzhH'></ins><ul id='uWzhH'></ul><sub id='uWzhH'></sub></form><legend id='uWzhH'></legend><bdo id='uWzhH'><pre id='uWzhH'><center id='uWzhH'></center></pre></bdo></b><th id='uWzhH'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='uWzhH'><tfoot id='uWzhH'></tfoot><dl id='uWzhH'><fieldset id='uWzhH'></fieldset></dl></div>
                        <legend id='uWzhH'><style id='uWzhH'><dir id='uWzhH'><q id='uWzhH'></q></dir></style></legend>

                        <tfoot id='uWzhH'></tfoot>

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

                            主站蜘蛛池模板: 欧洲高清转码区一二区 | 伊人网在线播放 | 性网站免费 | 精品久久久久久亚洲综合网 | 亚洲欧美少妇 | 久久久久免费观看 | 亚洲精品综合 | 久久国产一区二区三区 | 国产一级视频 | 日本精品免费在线观看 | 欧美精品综合 | 天天插天天搞 | 国产黄色大片在线免费观看 | 欧美日一区二区 | 精品国产一区二区三区日日嗨 | 久久亚洲一区二区三区四区 | 欧美性另类 | 国产成人在线一区 | 色资源在线视频 | 国产亚洲一区在线 | 精久久久 | 美女黄视频网站 | 国产麻豆乱码精品一区二区三区 | 中日韩av | 天堂色| 综合一区 | 91在线精品秘密一区二区 | 国产成人精品av | 亚洲精品福利视频 | 在线免费观看亚洲 | 黄网站色大毛片 | 免费特黄视频 | 亚洲高清视频一区二区 | 成人久久18免费网站 | 日韩欧美一级精品久久 | 国产一区欧美 | 欧美精品一区二区在线观看 | 亚洲国产一区二区三区 | 欧美综合视频在线 | 久久精品国产久精国产 | 欧美一区二区三区精品免费 |