[Pyrex] module scope, and threads
ahalda at cs.mcgill.ca
ahalda at cs.mcgill.ca
Sun Sep 3 22:12:13 UTC 2006
[[Argh. Again. This isn't the email/webmail I usually use (spam), so I'm
not used to it. Sorry. :( ]]
On Sun, September 3, 2006 4:03 pm, Daniele Varrazzo wrote:
> In pure Python you would have found the same "issue".
Oh, ok. Oops. I hadn't come across that yet.
> but i guess you'd better use the macros Py_INCREF and Py_DECREF and avoid
> the global variable (for examle, more threads may share the same resource
> without messing up with the global reference). See
> http://docs.python.org/api/countingRefs.html
Aha, I hadn't thought of using those from within pyrex. But you can.
But I still need the global variable in my case, since I need to
'remember' which object I need to decref, even between function calls. I
only process one object at a time, so every time I call my ProcessData(),
I just assign the global var to the new object I need to hold a reference
to. (and so the previous object gets decref'ed automatically)
Its a simple solution and it doesn't really hurt to have that extra
variable (which is hidden from python).
Thanks,
Allan
More information about the Pyrex
mailing list