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

    1. <legend id='Svwjh'><style id='Svwjh'><dir id='Svwjh'><q id='Svwjh'></q></dir></style></legend>

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

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

      1. <tfoot id='Svwjh'></tfoot>
          <bdo id='Svwjh'></bdo><ul id='Svwjh'></ul>

      2. Python 3:Pool 是否保持傳遞給 map 的原始數據順序

        Python 3: does Pool keep the original order of data passed to map?(Python 3:Pool 是否保持傳遞給 map 的原始數據順序?)

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

        • <bdo id='CwDWS'></bdo><ul id='CwDWS'></ul>
            <tbody id='CwDWS'></tbody>

              <tfoot id='CwDWS'></tfoot>

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

                  <legend id='CwDWS'><style id='CwDWS'><dir id='CwDWS'><q id='CwDWS'></q></dir></style></legend>
                • 本文介紹了Python 3:Pool 是否保持傳遞給 map 的原始數據順序?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我編寫了一個小腳本來在 4 個線程之間分配工作負載并測試結果是否保持有序(相對于輸入的順序):

                  I have written a little script to distribute workload between 4 threads and to test whether the results stay ordered (in respect to the order of the input):

                  from multiprocessing import Pool
                  import numpy as np
                  import time
                  import random
                  
                  
                  rows = 16
                  columns = 1000000
                  
                  vals = np.arange(rows * columns, dtype=np.int32).reshape(rows, columns)
                  
                  def worker(arr):
                      time.sleep(random.random())        # let the process sleep a random
                      for idx in np.ndindex(arr.shape):  # amount of time to ensure that
                          arr[idx] += 1                  # the processes finish at different
                                                         # time steps
                      return arr
                  
                  # create the threadpool
                  with Pool(4) as p:
                      # schedule one map/worker for each row in the original data
                      q = p.map(worker, [row for row in vals])
                  
                  for idx, row in enumerate(q):
                      print("[{:0>2}]: {: >8} - {: >8}".format(idx, row[0], row[-1]))
                  

                  對我來說,這總是會導致:

                  For me this always results in:

                  [00]:        1 -  1000000
                  [01]:  1000001 -  2000000
                  [02]:  2000001 -  3000000
                  [03]:  3000001 -  4000000
                  [04]:  4000001 -  5000000
                  [05]:  5000001 -  6000000
                  [06]:  6000001 -  7000000
                  [07]:  7000001 -  8000000
                  [08]:  8000001 -  9000000
                  [09]:  9000001 - 10000000
                  [10]: 10000001 - 11000000
                  [11]: 11000001 - 12000000
                  [12]: 12000001 - 13000000
                  [13]: 13000001 - 14000000
                  [14]: 14000001 - 15000000
                  [15]: 15000001 - 16000000
                  

                  問題:那么,Poolq<中存儲每個map函數的結果時,是否真的保持原始輸入的順序?/代碼>?

                  Question: So, does Pool really keep the original input's order when storing the results of each map function in q?

                  旁注:我問這個,因為我需要一種簡單的方法來并行處理多個工人的工作.在某些情況下,排序無關緊要.但是,在某些情況下(如 q 中的結果)必須以原始順序返回,因為我使用了一個依賴于有序數據的附加 reduce 函數.

                  Sidenote: I am asking this, because I need an easy way to parallelize work over several workers. In some cases the ordering is irrelevant. However, there are some cases where the results (like in q) have to be returned in the original order, because I'm using an additional reduce function that relies on ordered data.

                  性能:在我的機器上,這個操作比在單個進程上的正常執行快了大約 4 倍(正如預期的那樣,因為我有 4 個內核).此外,所有 4 個內核在運行時均處于 100% 的使用率.

                  Performance: On my machine this operation is about 4 times faster (as expected, since I have 4 cores) than normal execution on a single process. Additionally, all 4 cores are at 100% usage during the runtime.

                  推薦答案

                  Pool.map 結果是有序的.如果您需要訂購,很好;如果你不這樣做,池.imap_unordered 可能是一個有用的優化.

                  Pool.map results are ordered. If you need order, great; if you don't, Pool.imap_unordered may be a useful optimization.

                  請注意,雖然您從 Pool.map 接收結果的順序是固定的,但它們的計算順序是任意的.

                  Note that while the order in which you receive the results from Pool.map is fixed, the order in which they are computed is arbitrary.

                  這篇關于Python 3:Pool 是否保持傳遞給 map 的原始數據順序?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='FynzF'><style id='FynzF'><dir id='FynzF'><q id='FynzF'></q></dir></style></legend>
                        • <bdo id='FynzF'></bdo><ul id='FynzF'></ul>

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

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

                              <tbody id='FynzF'></tbody>
                            主站蜘蛛池模板: 国产成人亚洲精品 | 中文字幕人成人 | 亚洲一区二区三区免费在线观看 | 欧美一区二区视频 | 日本三级电影免费观看 | 狠狠干天天干 | 久久大| 蜜臀久久| 欧美日韩视频在线第一区 | 亚洲天堂一区二区 | 黄色片免费看 | 亚洲精品久久久久久国产精华液 | 久久久女女女女999久久 | 欧美极品在线观看 | 亚洲精品久久久久国产 | 欧美精品一区在线发布 | 亚洲精品2区 | 久久久久久久成人 | 国产资源一区二区三区 | 91在线精品秘密一区二区 | 久久精品国产一区 | 特黄级国产片 | 免费在线视频一区二区 | 欧美精品一区二区三区一线天视频 | 午夜激情在线 | 一级片av | 欧美在线观看黄色 | 91精品国产日韩91久久久久久 | 高清亚洲 | 国产在线播放一区二区三区 | 久久久片 | 国产欧美日韩在线播放 | 欧美色性| 国产91精品在线 | 亚洲情侣视频 | 久久精选 | 国产精品污www一区二区三区 | 日本高清视频在线播放 | 亚洲日本一区二区 | 日韩国产黄色片 | 在线不卡视频 |