【问题标题】:improving processing speed of python code in jupyter notebook提高 jupyter notebook 中 python 代码的处理速度
【发布时间】:2019-04-25 16:27:08
【问题描述】:

我有一个 Python 脚本,处理 300 万行的数据集,CPU 使用率只有 25%,那么如何通过在 CPU 中使用多核或充分利用 CPU 来提高处理速度来提高处理速度?

多处理和进程池所需的输入。

【问题讨论】:

  • 改进格式和语法

标签: python python-3.x jupyter-notebook anaconda


【解决方案1】:
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)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-12-14
    • 2020-08-16
    • 2019-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多