forked from gefarion/python2go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentities.py
38 lines (28 loc) · 785 Bytes
/
entities.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import md5
import cython
class TestObj(object):
def __init__(self, num, string):
self.num = num
self.string = string
@property
def num_times_string(self):
return self.string * self.num
@cython.locals(a = int, b = int, c = int)
def fibonacci(self):
a = 0
b = 1
for i in xrange(self.num):
t = a
a += b
b = t
return t
def md5(self):
m = md5.new()
m.update(self.string)
return m.hexdigest()
def clone(self, times=1):
return TestObj(self.num * times, self.string * times)
def explode(self):
raise Exception("Booom!")
def __eq__(self, other):
return self.num == other.num and self.string == other.string