为了减少我的计算时间,在下面的帖子中,有人告诉我将 map 与 concurrent.futures 一起使用。但我无法读取结果,我得到“0x7f0ef48ff2d0> 处的生成器对象映射”......我该怎么做?
import concurrent.futures
import numpy
def f(num):
return num * 2
arr = numpy.array(
[numpy.array([
numpy.array([1,2,3]),
numpy.array([4,5,6]),
numpy.array([7,8,9])]),
numpy.array([
numpy.array([1,2,3]),
numpy.array([4,5,6]),
numpy.array([7,8,9])])])
with concurrent.futures.ProcessPoolExecutor() as exc:
print(exc.map(f, arr))