Cython has moved to github.
cython-devel
view tests/run/exarkun.pyx @ 1622:4f0327bdebc9
test for temp allocation bug in call
| author | Robert Bradshaw <robertwb@math.washington.edu> |
|---|---|
| date | Sat Jan 17 01:25:34 2009 -0800 (3 years ago) |
| parents | ff6249a604c2 |
| children |
line source
1 __doc__ = u"""
2 >>> p = Point(1,2,3)
3 >>> p.gettuple()
4 (1.0, 2.0, 3.0)
5 >>> q = p + Point(2,3,4)
6 >>> q.gettuple()
7 (3.0, 5.0, 7.0)
8 >>> p.gettuple()
9 (1.0, 2.0, 3.0)
10 """
12 cdef class Point:
13 cdef double x, y, z
14 def __init__(self, double x, double y, double z):
15 self.x = x
16 self.y = y
17 self.z = z
19 # XXX: originally, this said "def __add__(self, other)"
20 def __add__(Point self, Point other):
21 return Point(self.x + other.x, self.y + other.y, self.z + other.z)
23 def gettuple(self):
24 return (self.x, self.y, self.z)
