0.1.186
This commit is contained in:
		@@ -1,7 +1,7 @@
 | 
			
		||||
[metadata]
 | 
			
		||||
# replace with your username:
 | 
			
		||||
name = guan
 | 
			
		||||
version = 0.1.185
 | 
			
		||||
version = 0.1.186
 | 
			
		||||
author = guanjihuan
 | 
			
		||||
author_email = guanjihuan@163.com
 | 
			
		||||
description = An open source python package
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
Metadata-Version: 2.4
 | 
			
		||||
Name: guan
 | 
			
		||||
Version: 0.1.185
 | 
			
		||||
Version: 0.1.186
 | 
			
		||||
Summary: An open source python package
 | 
			
		||||
Home-page: https://py.guanjihuan.com
 | 
			
		||||
Author: guanjihuan
 | 
			
		||||
 
 | 
			
		||||
@@ -29,16 +29,15 @@ def try_except(function_name, *args, **kwargs):
 | 
			
		||||
 | 
			
		||||
# 使用 multiprocessing.Pool 实现自动分配任务并行
 | 
			
		||||
def parallel_calculation_with_multiprocessing_Pool(func, args_list=[1, 2, 3], show_time=0):
 | 
			
		||||
    if __name__ == '__main__':
 | 
			
		||||
        import multiprocessing
 | 
			
		||||
        import time
 | 
			
		||||
        start_time = time.time()
 | 
			
		||||
        with multiprocessing.Pool() as pool:
 | 
			
		||||
            result_array = pool.map(func, args_list)
 | 
			
		||||
        end_time = time.time()
 | 
			
		||||
        if show_time:
 | 
			
		||||
            print(end_time - start_time)
 | 
			
		||||
        return result_array
 | 
			
		||||
    import multiprocessing
 | 
			
		||||
    import time
 | 
			
		||||
    start_time = time.time()
 | 
			
		||||
    with multiprocessing.Pool() as pool:
 | 
			
		||||
        result_array = pool.map(func, args_list)
 | 
			
		||||
    end_time = time.time()
 | 
			
		||||
    if show_time:
 | 
			
		||||
        print(end_time - start_time)
 | 
			
		||||
    return result_array
 | 
			
		||||
 | 
			
		||||
# 循环一个参数计算某个函数,并返回计算结果的数组
 | 
			
		||||
def loop_calculation_with_one_parameter(function_name, parameter_array):
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user