1
PYTHON setup.py build_ext --inplace
2
PYTHON -c "import a; a.test(a)"
4
######## setup.py ########
6
from Cython.Build.Dependencies import cythonize
8
from distutils.core import setup
11
ext_modules=cythonize("a.py"),
17
class ExtTypePass(object):
21
class ExtTypePxdDocstring(object):
25
class ExtTypeDocstring(object):
26
"""huhu!""" # this should override the .pxd docstring
29
class ExtTypeAttributes(object):
31
>>> x = ExtTypeAttributes()
47
x = bytearray(b'abcdefg')
58
def sum_generator_expression(a):
59
# GH-3477 - closure variables incorrectly captured in functions transformed to cdef
60
return sum(i for i in range(a))
62
def run_sum_generator_expression(a):
64
>>> run_sum_generator_expression(5)
67
return sum_generator_expression(a)
72
assert not os.path.basename(__file__).endswith('.py'), __file__
73
assert not os.path.basename(__file__).endswith('.pyc'), __file__
74
assert not os.path.basename(__file__).endswith('.pyo'), __file__
76
assert not ExtTypePass().__doc__, ExtTypePass().__doc__
77
assert ExtTypeDocstring().__doc__ == "huhu!", ExtTypeDocstring().__doc__
78
assert ExtTypePxdDocstring().__doc__ == "ho, ho, ho!", ExtTypePxdDocstring().__doc__
79
assert '>>> ' in func.__doc__
82
result = doctest.testmod(module, verbose=True)
83
assert not result.failed, result.failed
86
######## a.pxd ########
90
cdef class ExtTypePass:
94
cdef class ExtTypePxdDocstring:
98
cdef class ExtTypeAttributes:
103
cdef class TypedMethod:
104
@cython.locals(x='char[:]')
108
cpdef int func(x, int y, z) except? -1 # argument names should not matter, types should
111
cdef int sum_generator_expression(int a)