[Cython] Best way to link in Cython utility code?

Dag Sverre Seljebotn dagss at student.matnat.uio.no
Sat Dec 20 12:25:09 CET 2008


Stefan Behnel wrote:
> Dag Sverre Seljebotn wrote:
>> For the refcount nanny, I have a file refcheck.pyx which exports several
>> functions which is called from Cython-generated C code if a flag is set,
>> to do the reference nannying (basically they are "filters" for Py_...REF
>> calls, called (__Pyx_RefcheckerIncRef and so on).
>>
>> Currently, I hack this to work by manually including "cimport refcheck" in
>> my (single) testcase, and declare the functions as "api", leaving it to
>> the Cython-specific protocol to do the "linking"/pointer retrieval. This
>> give me what I need for developing it, but no more...
> 
> I'd try to use the .pxi include mechanism (somehow) from within Cython, to
> get it into the same file.

Could be done. However there's a problem: I wouldn't like the refcont 
nanny itself to be refcount nannied, to avoid infinite loops.

I suppose I can put in locks to (rather easily) overcome this, still 
compiling the refcount nanny in a seperate stage with different flags 
and linking it in seems rather more elegant *shrug*.

-- 
Dag Sverre


More information about the Cython-dev mailing list