<josef.p...@gmail.com> wrote:

> statsmodels still has avoided anything that smells like a global state that
> changes calculation.

If global states are stored in a stack, as in OpenGL, it is not so bad. A
context manager could push a state in __enter__ and pop the state in
__exit__. This is actually how I write OpenGL code in Python and Cython:
pairs of glBegin/glEnd, glPushMatrix/glPopMatrix, and
glPushAttrib/glPopAttrib nicely fits with Python context managers. 

However, the bigger issue is multithreading scalability. You need to
protect the global state with a recursive lock, and it might not scale like
you want. A thread might call a lengthy computation that releases the GIL,
but still hold the rlock that protects the state. All your hopes for seing
more then one core saturated will go down the drain. It is even bad for i/o
bound code, e.g. on-line signal processing: Data might be ready for
processing in one thread, but the global state is locked by an idle thread
waiting for data. 

Sturla

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to