Commit 32ac0752 authored by W. Trevor King's avatar W. Trevor King Committed by Robert Bradshaw

`int` -> `cdef int` when declaring local variables in early binding example.

parent 0b32583c
...@@ -53,7 +53,7 @@ where calls occur within Cython code. For example: ...@@ -53,7 +53,7 @@ where calls occur within Cython code. For example:
def __init__(self, int x0, int y0, int x1, int y1): def __init__(self, int x0, int y0, int x1, int y1):
self.x0 = x0; self.y0 = y0; self.x1 = x1; self.y1 = y1 self.x0 = x0; self.y0 = y0; self.x1 = x1; self.y1 = y1
cdef int _area(self): cdef int _area(self):
int area cdef int area
area = (self.x1 - self.x0) * (self.y1 - self.y0) area = (self.x1 - self.x0) * (self.y1 - self.y0)
if area < 0: if area < 0:
area = -area area = -area
...@@ -88,7 +88,7 @@ overheads. Consider this code: ...@@ -88,7 +88,7 @@ overheads. Consider this code:
def __init__(self, int x0, int y0, int x1, int y1): def __init__(self, int x0, int y0, int x1, int y1):
self.x0 = x0; self.y0 = y0; self.x1 = x1; self.y1 = y1 self.x0 = x0; self.y0 = y0; self.x1 = x1; self.y1 = y1
cpdef int area(self): cpdef int area(self):
int area cdef int area
area = (self.x1 - self.x0) * (self.y1 - self.y0) area = (self.x1 - self.x0) * (self.y1 - self.y0)
if area < 0: if area < 0:
area = -area area = -area
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment