Cython: Static Type für Membervariable



  • Hallo,

    wie teile ich cython mit, dass ein Member einer Python Klasse einen bestimmten Typ hat?

    class A(object):
        def __init__(self, int a):
            cdef int self.a = a
    

    Funktioniert leider nicht

    class A(object):
        cdef int a
        def __init__(self, int a):
            self.a = a
    

    Ebenfalls nicht. Eine cdef class möchte ich eigentlich nicht machen. Oder komme ich darum nicht herum?

    Vielen Dank für hilfreiche Antworten

    Gruß
    Mario


Anmelden zum Antworten