久久久久久久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精品国产综合久久久久久丝袜 | 国产精品国产三级国产aⅴ入口 | 亚洲欧美一区二区三区在线 | 九色在线| 国产高清在线观看 | 夜夜夜夜草 | 欧美日韩福利视频 | 美日韩免费视频 | a级在线免费视频 | 99综合| 国产精品日韩欧美一区二区 | 久久成人综合 | 久久免费视频网 | 拍真实国产伦偷精品 | 国产玖玖 | 伊人手机在线视频 | 亚洲精品福利在线 | a级在线免费视频 | av先锋资源 | 欧美一级片 | 国产精品免费一区二区 | 日本欧美在线观看视频 | 久久久久国产精品一区二区 | 久久se精品一区精品二区 | 欧美激情 亚洲 | 久久网一区二区 | 成人av在线播放 | 欧美精品成人一区二区三区四区 | 欧美一区不卡 | 亚洲欧美国产毛片在线 | 精品欧美一区二区三区久久久 | v片网站 | 欧美日韩在线一区二区 | 国产精品1区 | 亚洲精色 | 中文字幕在线一区二区三区 | 国产精品免费观看 | 久久一区二区视频 | 91精品国产91久久久久久最新 |