Threading in Python using multiple cores -


as far know, python's threading library uses posix threads threading , not run on multiple cores. possible implement multicore threading system python threads using open mp?

cpython ("default" python implementation) not utilizing multiple cores because of global interpreter lock. every python statement has hold lock.

but modules written in c may release interpreter lock before time-consuming operation. i.e. numpy that: http://wiki.scipy.org/parallelprogramming

they have handy example that:

import numpy np import math  def f(x):     print x     # statements hold gil , cannot run     # in 2 parallel threads      y = [1]*10000000     [math.exp(i) in y]  def g(x):     print x     # statements fall numpy c code     # release gil , can multithreaded     y = np.ones(10000000)     np.exp(y) 

since openmp tool c, think seek for.


Comments

Popular posts from this blog

python - Mongodb How to add addtional information when aggregating? -

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

ruby - Net::HTTP extremely slow responses for HTTPS requests -