【发布时间】:2019-04-25 16:27:08
【问题描述】:
我有一个 Python 脚本,处理 300 万行的数据集,CPU 使用率只有 25%,那么如何通过在 CPU 中使用多核或充分利用 CPU 来提高处理速度来提高处理速度?
多处理和进程池所需的输入。
【问题讨论】:
-
改进格式和语法
标签: python python-3.x jupyter-notebook anaconda
我有一个 Python 脚本,处理 300 万行的数据集,CPU 使用率只有 25%,那么如何通过在 CPU 中使用多核或充分利用 CPU 来提高处理速度来提高处理速度?
多处理和进程池所需的输入。
【问题讨论】:
标签: python python-3.x jupyter-notebook anaconda
import multiprocessing
pool = multiprocessing.Pool(multiprocessing.cpu_count())
def some_function_you_want_executed_in_parallel(args):
pass # logic goes here
arg_list = [] # put input arguments here
results = pool.map(some_function_you_want_executed_in_parallel, arg_list)
【讨论】: