3
from cython cimport _testscope as tester
4
from cython cimport TestClass, _testclass_new as TestClass_New
5
from cython cimport test_call, test_dep
6
from cython.view cimport _testscope as viewtester
8
from cpython cimport PyObject
12
cdef struct __pyx_TestClass_obj:
16
cdef PyObject *TestClassType "__pyx_TestClass_type"
18
# This is a cdef function
19
cdef __pyx_TestClass_New(int)
21
# These are methods and therefore have no prototypes
22
cdef __pyx_TestClass_cdef_method(TestClass self, int value)
23
cdef __pyx_TestClass_cpdef_method(TestClass self, int value, int skip_dispatch)
24
cdef __pyx_TestClass_def_method(object self, object value)
26
cdef __pyx_TestClass_cdef_cname(TestClass self, int value)
27
cdef __pyx_TestClass_cpdef_cname(TestClass self, int value, int skip_dispatch)
28
cdef __pyx_TestClass_def_cname(object self, object value)
30
cdef __pyx_test_dep(object)
31
cdef __pyx_test_call_other_cy_util(object)
34
def test_cdef_cython_utility():
36
>>> test_cdef_cython_utility()
37
hello from cython scope, value=4
38
hello from cython.view scope, value=4
39
hello from cython scope, value=3
40
hello from cython.view scope, value=3
42
print cython._testscope(4)
43
print cython.view._testscope(4)
47
def test_cdef_class_cython_utility():
49
>>> test_cdef_class_cython_utility()
55
cdef __pyx_TestClass_obj *objstruct
57
obj = TestClass_New(7)
58
objstruct = <__pyx_TestClass_obj *> obj
61
obj = __pyx_TestClass_New(14)
62
objstruct = <__pyx_TestClass_obj *> obj
65
print (<object> TestClassType)(20)
68
def test_extclass_c_methods():
70
>>> test_extclass_c_methods()
71
Hello from cdef_method 1
72
Hello from cpdef_method 2
73
Hello from def_method 3
74
Hello from cdef_cname_method 4
75
Hello from cpdef_cname_method 5
76
Hello from def_cname_method 6
77
Hello from cdef_method 1
78
Hello from cpdef_method 2
79
Hello from def_method 3
80
Hello from cdef_cname_method 4
81
Hello from cpdef_cname_method 5
82
Hello from def_cname_method 6
84
cdef TestClass obj1 = TestClass(11)
85
cdef TestClass obj2 = TestClass_New(22)
87
__pyx_TestClass_cdef_method(obj1, 1)
88
__pyx_TestClass_cpdef_method(obj1, 2, True)
89
__pyx_TestClass_def_method(obj1, 3)
91
__pyx_TestClass_cdef_cname(obj1, 4)
92
__pyx_TestClass_cpdef_cname(obj1, 5, True)
93
__pyx_TestClass_def_cname(obj1, 6)
95
__pyx_TestClass_cdef_method(obj2, 1)
96
__pyx_TestClass_cpdef_method(obj2, 2, True)
97
__pyx_TestClass_def_method(obj2, 3)
99
__pyx_TestClass_cdef_cname(obj2, 4)
100
__pyx_TestClass_cpdef_cname(obj2, 5, True)
101
__pyx_TestClass_def_cname(obj2, 6)
103
def test_extclass_cython_methods():
105
>>> test_extclass_cython_methods()
106
Hello from cdef_method 1
107
Hello from cpdef_method 2
108
Hello from def_method 3
109
Hello from cdef_cname_method 4
110
Hello from cpdef_cname_method 5
111
Hello from def_cname_method 6
112
Hello from cdef_method 1
113
Hello from cpdef_method 2
114
Hello from def_method 3
115
Hello from cdef_cname_method 4
116
Hello from cpdef_cname_method 5
117
Hello from def_cname_method 6
119
cdef TestClass obj1 = TestClass(11)
120
cdef TestClass obj2 = TestClass_New(22)
125
obj1.cdef_cname_method(4)
126
obj1.cpdef_cname_method(5)
127
obj1.def_cname_method(6)
132
obj2.cdef_cname_method(4)
133
obj2.cpdef_cname_method(5)
134
obj2.def_cname_method(6)
136
def test_cython_utility_dep():
138
>>> test_cython_utility_dep()
148
__pyx_test_dep('third')
149
__pyx_test_call_other_cy_util('fourth')
154
<strided and direct or indirect>
156
<strided and indirect>
157
<contiguous and direct>
158
<contiguous and indirect>
160
print cython.view.generic
161
print cython.view.strided
162
print cython.view.indirect
163
#print cython.view.generic_contiguous
164
print cython.view.contiguous
165
print cython.view.indirect_contiguous