首页 > 解决方案 > 将 hylang 与 python 多处理一起使用的示例

问题描述

我正在寻找一个将 python 多处理(即进程池/线程池、作业队列等)与 hylang 一起使用的示例。

标签: multiprocessingpython-multiprocessinghy

解决方案


文档中的第一个示例multiprocessing可以直译为 Hy,如下所示:

(import multiprocessing [Pool])

(defn f [x]
  (* x x))

(when (= __name__ "__main__")
  (with [p (Pool 5)]
    (print (.map p f [1 2 3]))))

推荐阅读