multirhreading&boost.python

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon May 5 00:11:02 EDT 2008


En Sun, 04 May 2008 11:56:14 -0300, joop renes <jj.renes at hccnet.nl> escribió:

> i hope this is the right list for the following question of a c++
> hacker,python newbie. i have a library in c++ to which i want to add a
> python GUI and other python stuff.The library has multithreading
> components, while python uses a reference counted memory model. Usually
> mixing reference counting with multithreading is frowned upon, at least
> in the c++ world. what am i to expect in the python world, if i bring
> multithreading c++ into it? just performance penalty or total disaster?
> best regards

Python objects are reference counted, *and* you can have many threads running. This is not a problem in itself; Python has a Global Interpreter Lock (GIL) that ensures that addref/releases are properly handled. Only one thread at a time can execute Python code; but your C++ library can use as many threads as you want - as long as they don't call Python code again without reacquiring the GIL.

-- 
Gabriel Genellina




More information about the Python-list mailing list