[Pyrex] module scope, and threads

ahalda at cs.mcgill.ca ahalda at cs.mcgill.ca
Mon Sep 4 00:33:32 UTC 2006


On Sun, September 3, 2006 7:07 pm, Greg Ewing wrote:
> ahalda at cs.mcgill.ca wrote:
>> My solution was to create a module level pyrex object to keep at least
>> one reference to the object active, for as long as the background thread
>> needs the object.
>
> That really should be the responsibility of the
> C function that you're passing the object reference
> to. Although if the calling module can be sure that the previous object is
> no longer needed before replacing it with a new one, this will work.

Well, I am wrapping a library I didn't write. Also: If the c had python.h
available so it could DECREF and INCREF I agree. But a pure C function
(without Python.h) couldn't stop python from calling free(), I think.

I guess C programs with memory management will be a little harder to
convert to python, since python automatically does that for you in its own
way. It's all easier in python :)

Thanks,
Allan






More information about the Pyrex mailing list