[Cython] Refcount error with fused types in classes

Pauli Virtanen pav at iki.fi
Sun Mar 17 17:15:51 CET 2013


Hi,

Here's a snippet demonstrating a refcount error with fused types inside
classes:

---------8<---------
cimport cython

ctypedef fused some_t:
    int
    double

class Foo(object):
    def bar(self, some_t x):
        pass

cdef extern from "Python.h":
    int Py_REFCNT(object)

def main():
    x = Foo()
    print "before:", Py_REFCNT(x)
    x.bar(1.0) # spuriously increments refcount of `x`
    print "after: ", Py_REFCNT(x)
---------8<---------


-- 
Pauli Virtanen



More information about the cython-devel mailing list