In [1]:
%load_ext cython

Our lovely Cython types


In [2]:
%%cython
cdef class A:
    def __cinit__(self):
        print('A.__cinit__() called.')
    def __init__(self):
        print('A.__init__() called.')
    
cdef class B(A):
    def __init__(self):
        super().__init__()

cdef class C(A):
    def __init__(self):
        super().__init__()

In [3]:
b = B()


A.__cinit__() called.
A.__init__() called.

Someone uses our code, and they don't like super()


In [4]:
# 😭 Some user avoids super and called the constructors directly.
class D(B, C):
    def __init__(self):
        B.__init__(self)
        C.__init__(self)

In [5]:
d = D()


A.__cinit__() called.
A.__init__() called.
A.__init__() called.

Someone uses our code, and they don't call init() at all


In [6]:
# 😭 Some user avoids calling super entirely
class E(B, C):
    def __init__(self):
        print("I'm super enough already 😇")

In [7]:
e = E()


A.__cinit__() called.
I'm super enough already 😇

In [ ]: