cython

Форк
0
/
cimport.srctree 
78 строк · 1.4 Кб
1
PYTHON setup.py build_ext --inplace
2
PYTHON -c "import a"
3
# Rebuild it with a flag to pretend we're on a platform where sizeof(function_ptr) != sizeof(void*)
4
PYTHON setup_large_func_pointers.py build_ext --inplace --force
5
PYTHON -c "import a"
6

7
######## setup.py ########
8

9

10
from Cython.Build import cythonize
11
from distutils.core import setup
12

13
setup(
14
  ext_modules = cythonize("*.pyx"),
15
)
16

17
######## setup_large_func_pointers.py ########
18

19

20
from Cython.Build import cythonize
21
from distutils.core import setup, Extension
22

23
setup(
24
  ext_modules = cythonize(Extension("*", ["*.pyx"],
25
                                    extra_compile_args=["-D__Pyx_TEST_large_func_pointers=1"])),
26
)
27

28
######## other.pxd ########
29

30
cdef class A:
31
    pass
32

33
cdef int foo(int)
34

35
######## other.pyx ########
36

37
cdef class A:
38
    pass
39

40
cdef int foo(int a):
41
     return a**2
42

43
######## pkg/__init__.py ########
44

45

46
######## pkg/sub.pxd ########
47

48
ctypedef int my_int
49

50
######## pkg/subpkg/__init__.py ########
51

52
######## pkg/subpkg/submod.pxd ########
53

54
ctypedef int my_int
55

56
######## a.pyx ########
57

58
from other cimport (
59
    A,
60
    foo,
61
)
62
print(A, foo(10))
63

64
cimport other
65

66
cdef call_fooptr(int (*fptr)(int)):
67
    return fptr(10)
68

69
def call_other_foo():
70
    x = other.foo  # GH4000 - failed because other was untyped
71
    return call_fooptr(x) # check that x is correctly resolved as a function pointer
72

73
print(other.A, other.foo(10), call_other_foo())
74

75
from pkg cimport sub
76
cdef sub.my_int a = 100
77

78
from pkg.subpkg cimport submod
79

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.