每当我创建import numpy11 个子进程(我的 CPU 有 6/12 个核心/线程)时,即使不使用numpy ,也会创建。这种情况只会发生一小会儿,但每个子进程都会收到内存中分配的对象的副本。这没什么大不了的,因为它在一开始就发生了,但我担心任何可能的副作用。有人可以解释一下为什么会发生这种情况吗?
这是重现问题的非常简单的代码:
import time
import numpy
def hello_world():
print("Hello world")
time.sleep(10)
if __name__ == '__main__':
print("Running")
time.sleep(30)
hello_world()
Run Code Online (Sandbox Code Playgroud)