下面的代码处理大量数据,我想问一下如何使用 Python 中的多处理模块进行并行处理以加快处理速度。任何帮助表示赞赏
pats = []
for chunk in code_counter(patients, codes):
pats.append(chunk)
def code_counter(patients, codes):
for key, group in itertools.groupby(patients, key=operator.itemgetter('ID')):
group_codes = [item['CODE'] for item in group]
yield [group_codes.count(code) for code in codes]