blob: b10a2610a0ca41354498e40c8d2facd97b724eb6 (
plain)
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
39
40
41
42
|
# ticket: t608
# This only works reliably in Python2. In Python3 ints are variable-sized.
# You get away with it for small ints but it's a bad idea
cdef class MyInt(int):
"""
>>> MyInt(2) == 2
True
>>> MyInt(2).attr is None
True
"""
cdef readonly object attr
cdef class MyInt2(int):
"""
>>> MyInt2(2) == 2
True
>>> MyInt2(2).attr is None
True
>>> MyInt2(2).test(3)
5
"""
cdef readonly object attr
def test(self, arg):
return self._test(arg)
cdef _test(self, arg):
return self + arg
cdef class MyInt3(MyInt2):
"""
>>> MyInt3(2) == 2
True
>>> MyInt3(2).attr is None
True
>>> MyInt3(2).test(3)
6
"""
cdef _test(self, arg):
return self + arg + 1
|