Singleton is not working in Cython
问题 This is how i define Singleton. class Singleton(type): _instances = {} def __call__(cls, *args, **kwargs): if cls not in cls._instances: cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs) return cls._instances[cls] Then I have my classes defined as: class MyClass(object): __metaclass__ = Singleton def __init__(self): pass a = MyClass() b = MyClass() "a is b" will return True However, cdef class MyCythonClass(object): __metaclass__ = Singleton def __cinit__(self): pass c =