1cdef class Rectangle: 2 cdef int x0, y0 3 cdef int x1, y1 4 5 def __init__(self, int x0, int y0, int x1, int y1): 6 self.x0 = x0 7 self.y0 = y0 8 self.x1 = x1 9 self.y1 = y1 10 11 cdef int _area(self): 12 cdef int area = (self.x1 - self.x0) * (self.y1 - self.y0) 13 if area < 0: 14 area = -area 15 return area 16 17 def area(self): 18 return self._area() 19 20def rectArea(x0, y0, x1, y1): 21 cdef Rectangle rect = Rectangle(x0, y0, x1, y1) 22 return rect._area() 23