1. <tfoot id='0ASOX'></tfoot>
    <i id='0ASOX'><tr id='0ASOX'><dt id='0ASOX'><q id='0ASOX'><span id='0ASOX'><b id='0ASOX'><form id='0ASOX'><ins id='0ASOX'></ins><ul id='0ASOX'></ul><sub id='0ASOX'></sub></form><legend id='0ASOX'></legend><bdo id='0ASOX'><pre id='0ASOX'><center id='0ASOX'></center></pre></bdo></b><th id='0ASOX'></th></span></q></dt></tr></i><div id='0ASOX'><tfoot id='0ASOX'></tfoot><dl id='0ASOX'><fieldset id='0ASOX'></fieldset></dl></div>
      <bdo id='0ASOX'></bdo><ul id='0ASOX'></ul>

    <small id='0ASOX'></small><noframes id='0ASOX'>

  2. <legend id='0ASOX'><style id='0ASOX'><dir id='0ASOX'><q id='0ASOX'></q></dir></style></legend>

    1. “块大小"multiprocessing.Pool.map 中的参数

      时间:2023-05-26
    2. <small id='Vp6r2'></small><noframes id='Vp6r2'>

        <bdo id='Vp6r2'></bdo><ul id='Vp6r2'></ul>
        <legend id='Vp6r2'><style id='Vp6r2'><dir id='Vp6r2'><q id='Vp6r2'></q></dir></style></legend>

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

                本文介绍了“块大小"multiprocessing.Pool.map 中的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                例如,如果我有一个带有 2 个处理器的池对象:

                If I have a pool object with 2 processors for example:

                p=multiprocessing.Pool(2)
                

                我想遍历目录中的文件列表并使用 map 函数

                and I want to iterate over a list of files on directory and use the map function

                谁能解释一下这个函数的块大小是多少:

                could someone explain what is the chunksize of this function:

                p.map(func, iterable[, chunksize])
                

                如果我将 chunksize 例如设置为 10,这是否意味着每 10 个文件都应该使用一个处理器进行处理?

                If I set the chunksize for example to 10 does that means every 10 files should be processed with one processor?

                推荐答案

                看Pool.map 的文档 看来您几乎是正确的: chunksize 参数将导致可迭代对象被拆分为大约该大小,并且每件作品都作为单独的任务提交.

                Looking at the documentation for Pool.map it seems you're almost correct: the chunksize parameter will cause the iterable to be split into pieces of approximately that size, and each piece is submitted as a separate task.

                所以在您的示例中,是的,map 将采用前 10 个(大约),将其作为单个处理器的任务提交......然后接下来的 10 个将作为另一个任务提交,等等.请注意,这并不意味着这会使处理器每 10 个文件交替一次,很有可能处理器 #1 最终得到 1-10 和 11-20,而处理器 #2 得到 21-30 和 31-40.

                So in your example, yes, map will take the first 10 (approximately), submit it as a task for a single processor... then the next 10 will be submitted as another task, and so on. Note that it doesn't mean that this will make the processors alternate every 10 files, it's quite possible that processor #1 ends up getting 1-10 AND 11-20, and processor #2 gets 21-30 and 31-40.

                这篇关于“块大小"multiprocessing.Pool.map 中的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何在 FastAPI 中进行多处理 下一篇:Python 多处理库错误(AttributeError:__exit__)

                相关文章

                最新文章

                1. <i id='K5sBC'><tr id='K5sBC'><dt id='K5sBC'><q id='K5sBC'><span id='K5sBC'><b id='K5sBC'><form id='K5sBC'><ins id='K5sBC'></ins><ul id='K5sBC'></ul><sub id='K5sBC'></sub></form><legend id='K5sBC'></legend><bdo id='K5sBC'><pre id='K5sBC'><center id='K5sBC'></center></pre></bdo></b><th id='K5sBC'></th></span></q></dt></tr></i><div id='K5sBC'><tfoot id='K5sBC'></tfoot><dl id='K5sBC'><fieldset id='K5sBC'></fieldset></dl></div>
                  1. <tfoot id='K5sBC'></tfoot>

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

                  2. <legend id='K5sBC'><style id='K5sBC'><dir id='K5sBC'><q id='K5sBC'></q></dir></style></legend>
                      <bdo id='K5sBC'></bdo><ul id='K5sBC'></ul>