项目作者: CodingVanGogh

项目描述 :
Multi Threading and Multi Processing made easy in Python2.7
高级语言: Python
项目地址: git://github.com/CodingVanGogh/parallelization.git
创建时间: 2016-05-25T11:42:57Z
项目社区:https://github.com/CodingVanGogh/parallelization

开源协议:MIT License

下载


Parallelization for python2.7

This is a generic package for parallelization using Threads and Processes

Install using pip
  • pip install plmap
Install from the source

Example Usage

  1. def add(a, b): # Function to be called parallely
  2. return a + b
  1. input = [ [2, 3], [4, 5], [10, 11] ] # Set of inputs to the add function
  • Parallelization using Multi-Threading

    1. from plmap import plmapt
    2. errors, outputs = plmapt(add, input, [], 3, None)
    1. errors : [('0', 'None'), ('0', 'None'), ('0', 'None')]
    2. # [ ('<error_code>', '<error_description>') ..... ]
    3. outputs : [5, 9, 21]
    4. # [ <output for the first set of inputs>, <output for the second set of inputs> , ..... ]
  • Parallelization using Multi-Processing

    1. from plmap import plmapp
    2. errors, outputs = plmapp(add, input, [], 3, None)
    1. errors : [('0', 'None'), ('0', 'None'), ('0', 'None')]
    2. # [ ('<error_code>', '<error_description>') ..... ]
    3. outputs : [5, 9, 21]
    4. # [ <output for the first set of inputs>, <output for the second set of inputs> , ..... ]