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

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

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

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

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

    2. 使用 Python 將巨大的嵌套循環(huán)劃分為 8 個(gè)(或更多

      what is the neat way to divide huge nested loops to 8(or more) processes using Python?(使用 Python 將巨大的嵌套循環(huán)劃分為 8 個(gè)(或更多)進(jìn)程的巧妙方法是什么?)
          • <i id='mXWvS'><tr id='mXWvS'><dt id='mXWvS'><q id='mXWvS'><span id='mXWvS'><b id='mXWvS'><form id='mXWvS'><ins id='mXWvS'></ins><ul id='mXWvS'></ul><sub id='mXWvS'></sub></form><legend id='mXWvS'></legend><bdo id='mXWvS'><pre id='mXWvS'><center id='mXWvS'></center></pre></bdo></b><th id='mXWvS'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='mXWvS'><tfoot id='mXWvS'></tfoot><dl id='mXWvS'><fieldset id='mXWvS'></fieldset></dl></div>
              <tbody id='mXWvS'></tbody>

              <tfoot id='mXWvS'></tfoot>
              • <bdo id='mXWvS'></bdo><ul id='mXWvS'></ul>
                <legend id='mXWvS'><style id='mXWvS'><dir id='mXWvS'><q id='mXWvS'></q></dir></style></legend>

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

              • 本文介紹了使用 Python 將巨大的嵌套循環(huán)劃分為 8 個(gè)(或更多)進(jìn)程的巧妙方法是什么?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                問(wèn)題描述

                這一次我面臨一個(gè)設(shè)計(jì)"問(wèn)題.使用 Python,我實(shí)現(xiàn)了一個(gè)使用 5 個(gè)參數(shù)的數(shù)學(xué)算法.為了找到這 5 個(gè)參數(shù)的最佳組合,我使用 5 層嵌套循環(huán)來(lái)枚舉給定范圍內(nèi)的所有可能組合.完成所需的時(shí)間似乎超出了我的預(yù)期.所以我覺(jué)得是時(shí)候使用多線(xiàn)程了……

                this time i'm facing a "design" problem. Using Python, I have a implement a mathematical algorithm which uses 5 parameters. To find the best combination of these 5 parameters, i used 5-layer nested loop to enumerate all possible combinations in a given range. The time it takes to finish appeared to be beyond my expectation. So I think it's the time to use multithreading...

                嵌套循環(huán)的核心任務(wù)是計(jì)算和保存.在當(dāng)前代碼中,每個(gè)計(jì)算的結(jié)果都附加到一個(gè)列表中,并且該列表將在程序結(jié)束時(shí)寫(xiě)入一個(gè)文件.

                The task in the core of nested loops are calculation and saving. In current code, result from every calculation is appended to a list and the list will be written to a file at the end of program.

                由于我對(duì)任何語(yǔ)言的多線(xiàn)程都沒(méi)有太多經(jīng)驗(yàn),更不用說(shuō) Python,我想請(qǐng)教一些關(guān)于這個(gè)問(wèn)題的結(jié)構(gòu)應(yīng)該是什么的提示.即,如何將計(jì)算動(dòng)態(tài)分配給線(xiàn)程,線(xiàn)程如何保存結(jié)果,然后將所有結(jié)果合并到一個(gè)文件中.希望線(xiàn)程數(shù)可以調(diào)整.

                since I don't have too much experience of multithreading in any language, not to mention Python, I would like to ask for some hints on what should the structure be for this problem. Namely, how should the calculations be assigned to the threads dynamically and how should the threads save results and later combine all results into one file. I hope the number of threads can be adjustable.

                任何帶有代碼的插圖都會(huì)很有幫助.

                Any illustration with code will be very helpful.

                非常感謝您的寶貴時(shí)間,我很感激.

                thank you very much for your time, I appreciate it.

                第二天更新:感謝所有有用的答案,現(xiàn)在我知道它是多處理而不是多線(xiàn)程.我總是混淆這兩個(gè)概念,因?yàn)槲艺J(rèn)為如果它是多線(xiàn)程的,那么操作系統(tǒng)會(huì)在可用時(shí)自動(dòng)使用多個(gè)處理器來(lái)運(yùn)行它.今晚我會(huì)抽出時(shí)間來(lái)實(shí)踐一下多處理.

                update of 2nd Day: thanks for all helpful answers, now I know that it is multiprocessing instead of multithreading. I always confuse with these two concepts because I think if it is multithreaded then the OS will automatically use multiple processor to run it when available. I will find time to have some hands-on with multiprocessing tonight.

                推薦答案

                你可以嘗試使用jug,我為非常相似的問(wèn)題編寫(xiě)的一個(gè)庫(kù).然后你的代碼看起來(lái)像

                You can try using jug, a library I wrote for very similar problems. Your code would then look something like

                from jug import TaskGenerator
                evaluate = TaskGenerator(evaluate)
                
                for p0 in [1,2,3]:
                    for p1 in xrange(10):
                        for p2 in xrange(10,20):
                             for p3 in [True, False]:
                                for p4 in xrange(100):
                                    results.append(evaluate(p0,p1,p2,p3,p4))
                

                現(xiàn)在您可以運(yùn)行任意數(shù)量的進(jìn)程(如果您可以訪(fǎng)問(wèn)計(jì)算機(jī)集群,甚至可以跨網(wǎng)絡(luò)運(yùn)行).

                Now you could run as many processes as you'd like (even across a network if you have access to a computer cluster).

                這篇關(guān)于使用 Python 將巨大的嵌套循環(huán)劃分為 8 個(gè)(或更多)進(jìn)程的巧妙方法是什么?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                相關(guān)文檔推薦

                How to bind a function to an Action from Qt menubar?(如何將函數(shù)綁定到 Qt 菜單欄中的操作?)
                PyQt progress jumps to 100% after it starts(PyQt 啟動(dòng)后進(jìn)度躍升至 100%)
                How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?(如何將 yaxis 刻度標(biāo)簽設(shè)置在固定位置,以便當(dāng)我向左或向右滾動(dòng)時(shí),yaxis 刻度標(biāo)簽應(yīng)該可見(jiàn)
                `QImage` constructor has unknown keyword `data`(`QImage` 構(gòu)造函數(shù)有未知關(guān)鍵字 `data`)
                Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時(shí)顯示進(jìn)度條?)
                    <i id='mJOB8'><tr id='mJOB8'><dt id='mJOB8'><q id='mJOB8'><span id='mJOB8'><b id='mJOB8'><form id='mJOB8'><ins id='mJOB8'></ins><ul id='mJOB8'></ul><sub id='mJOB8'></sub></form><legend id='mJOB8'></legend><bdo id='mJOB8'><pre id='mJOB8'><center id='mJOB8'></center></pre></bdo></b><th id='mJOB8'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='mJOB8'><tfoot id='mJOB8'></tfoot><dl id='mJOB8'><fieldset id='mJOB8'></fieldset></dl></div>

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

                    <legend id='mJOB8'><style id='mJOB8'><dir id='mJOB8'><q id='mJOB8'></q></dir></style></legend>

                  1. <tfoot id='mJOB8'></tfoot>
                    • <bdo id='mJOB8'></bdo><ul id='mJOB8'></ul>

                            <tbody id='mJOB8'></tbody>
                          主站蜘蛛池模板: 欧美色综合一区二区三区 | 日韩精品一区在线 | 亚洲国产成人在线 | 亚洲欧美日韩精品久久亚洲区 | 91九色视频在线 | 亚洲精美视频 | 产真a观专区 | 日韩一区二区免费视频 | 久久久99精品免费观看 | 狠狠综合久久av一区二区老牛 | 人人艹人人 | 亚洲成人一区二区三区 | 亚洲在线一区 | 亚洲少妇综合网 | 大象一区 | 国产精品九九九 | 国产精品国产a级 | 成人网在线看 | 欧美一区免费 | 国产区在线看 | 国产色片| 看黄在线 | 久草视频在线播放 | 亚洲一区二区视频 | 日屁网站 | 天堂中文字幕av | 亚洲 欧美 激情 另类 校园 | 国产一区高清 | 久久一级| 亚洲精品欧美精品 | 97人人澡人人爽91综合色 | 国产一区二区黑人欧美xxxx | 欧美国产日韩成人 | avav在线看 | 欧美日韩高清在线观看 | 欧美日韩三级在线观看 | 精品一区二区三区在线视频 | 国产高清精品一区二区三区 | 91精品国产高清一区二区三区 | 日皮视频免费 | 成人国产精品 |