You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
is it possible to take the advantage of the cython nogil keyword? #128
I have a python http server hosting an indicator calculating service, which is using ta-lib. Now many clients are using this service simultaneously. The http service is multi-threaded, so the GIL is the bottleneck.
So we call the ta-lib C functions with a pointer to memory backing a numpy array. What I'm not sure about, is can that pointer change on you if python runs a GC and you aren't holding the GIL, could your pointer be stale?
The memory is owned by a python object, does that count? It's not obvious to me what happens with a GC triggered while we have a call into ta-lib with nogil.
Activity
mrjbq7 commentedon Nov 30, 2016
I'm not sure if the underlying
TA-LibC library is fully reentrant, but it seems like it could work.Is this a performance issue you're running into?
goldenbull commentedon Dec 1, 2016
I have a python http server hosting an indicator calculating service, which is using ta-lib. Now many clients are using this service simultaneously. The http service is multi-threaded, so the GIL is the bottleneck.
mrjbq7 commentedon Dec 23, 2016
So we call the ta-lib C functions with a pointer to memory backing a numpy array. What I'm not sure about, is can that pointer change on you if python runs a GC and you aren't holding the GIL, could your pointer be stale?
goldenbull commentedon Dec 23, 2016
to my limited knowledge from cython doc, it seems to be safe if no python object is referenced during the operation.
mrjbq7 commentedon Dec 23, 2016
The memory is owned by a python object, does that count? It's not obvious to me what happens with a GC triggered while we have a call into ta-lib with
nogil.goldenbull commentedon Dec 23, 2016
GC may move the python object, but will not move the pointer value in the object.
Here is an example about nogil and numpy in cython