human
I am working on the file "05_cython/05_cython.ipynb".
The first task is:
4.- Other advanced things you can do with Cython
We have seen that with Cython we can implement our algorithms achieving C performance. Moreover it is very versatile and we can do some other advanced thing with it:
Object-oriented programming: Classes and methods
To support object-oriented programming, Cython supports writing normal Python classes exactly as in Python.
Can you write Python program for it?
 ... What is a the Python program you requested?
assistant
#Here is the Python program you requested.

%%cython -a -c=-fPIC -c=-fwrapv -c=-O3 -c=-fno-strict-aliasing
#!python
#cython: cdivision=True, boundscheck=False, nonecheck=False, wraparound=False, initializedcheck=False

cdef class A(object):
    def   d(self): return 0
    cdef  int c(self): return 0
    cpdef int p(self): return 0

    def test_def(self, long num):
        while num > 0:
            self.d()
            num -= 1

    def test_cdef(self, long num):
        while num > 0:
            self.c()
            num -= 1

    def test_cpdef(self, long num):
        while num > 0:
            self.p()
            num -= 1

%%timeit n = 1000000
a1 = A()
a1.test_def(n)

%%timeit n = 1000000
a1 = A()
a1.test_cdef(n)

%%timeit n = 1000000
a1 = A()
a1.test_cpdef(n)