1. <small id='kLnxA'></small><noframes id='kLnxA'>

        <tfoot id='kLnxA'></tfoot>

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

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

      3. python多处理参数:深拷贝?

        时间:2023-05-25
          <i id='BjBfq'><tr id='BjBfq'><dt id='BjBfq'><q id='BjBfq'><span id='BjBfq'><b id='BjBfq'><form id='BjBfq'><ins id='BjBfq'></ins><ul id='BjBfq'></ul><sub id='BjBfq'></sub></form><legend id='BjBfq'></legend><bdo id='BjBfq'><pre id='BjBfq'><center id='BjBfq'></center></pre></bdo></b><th id='BjBfq'></th></span></q></dt></tr></i><div id='BjBfq'><tfoot id='BjBfq'></tfoot><dl id='BjBfq'><fieldset id='BjBfq'></fieldset></dl></div>
        • <tfoot id='BjBfq'></tfoot>
              <tbody id='BjBfq'></tbody>

            • <bdo id='BjBfq'></bdo><ul id='BjBfq'></ul>

              • <small id='BjBfq'></small><noframes id='BjBfq'>

                  <legend id='BjBfq'><style id='BjBfq'><dir id='BjBfq'><q id='BjBfq'></q></dir></style></legend>
                  本文介绍了python多处理参数:深拷贝?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..
                  from multiprocessing import Process
                  # c is a container
                  p = Process(target = f, args = (c,))
                  p.start()
                  

                  我假设 c 的深拷贝被传递给函数 f 因为浅拷贝在新进程的情况下没有意义(新进程不可以访问来自调用进程的数据).

                  I assume a deep copy of c is passed to function f because shallow copy would make no sense in the case of a new process (the new process doesn't have access to the data from the calling process).

                  但是这个深拷贝是如何定义的呢?copy 中有一整套 注释集.deepcopy() 文档,所有这些注释是否也适用于这里?multiprocessing 文档什么也没说...

                  But how is this deep copy defined? There is a whole set of notes in the copy.deepcopy() documentation, do all these notes apply here as well? The multiprocessing documentation says nothing...

                  推荐答案

                  当你创建一个 Process 实例时,Python 会在底层发出一个 fork().这会创建一个子进程,其内存空间是其父进程的精确副本——因此在 fork 时存在的所有内容都会被复制.

                  When you create a Process instance, under the hood Python issues a fork(). This creates a child process whose memory space is an exact copy of its parent -- so everything existing at the time of the fork is copied.

                  在 Linux 上,这是通过写时复制"来提高效率的.来自 fork 手册页:

                  On Linux this is made efficient through "copy-on-write". From the fork man page:

                  fork() 创建一个子进程仅与父进程不同在它的 PID 和 PPID 中,事实上资源利用率设置为0. 文件锁和挂起信号不被继承.

                  fork() creates a child process that differs from the parent process only in its PID and PPID, and in the fact that resource utilizations are set to 0. File locks and pending signals are not inherited.

                  Linux下实现fork()使用写时复制页面,所以唯一的它招致的惩罚是时间和复制所需的内存父的页表,并创建一个孩子的独特任务结构.

                  Under Linux, fork() is implemented using copy-on-write pages, so the only penalty that it incurs is the time and memory required to duplicate the parent's page tables, and to create a unique task structure for the child.

                  这篇关于python多处理参数:深拷贝?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:python multiprocessing BaseManager注册类在Ctrl-C后立即失 下一篇:Python 多处理只使用一个核心

                  相关文章

                  最新文章

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

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