Blame tests/run/array_cimport.srctree
|
Packit Service |
99d393 |
PYTHON setup.py build_ext --inplace
|
|
Packit Service |
99d393 |
PYTHON -c "import ttt"
|
|
Packit Service |
99d393 |
|
|
Packit Service |
99d393 |
######## setup.py ########
|
|
Packit Service |
99d393 |
|
|
Packit Service |
99d393 |
from Cython.Build.Dependencies import cythonize
|
|
Packit Service |
99d393 |
from distutils.core import setup
|
|
Packit Service |
99d393 |
|
|
Packit Service |
99d393 |
setup(
|
|
Packit Service |
99d393 |
ext_modules = cythonize("*.pyx"),
|
|
Packit Service |
99d393 |
)
|
|
Packit Service |
99d393 |
|
|
Packit Service |
99d393 |
|
|
Packit Service |
99d393 |
######## tt.pxd ########
|
|
Packit Service |
99d393 |
|
|
Packit Service |
99d393 |
from cpython.array cimport array
|
|
Packit Service |
99d393 |
|
|
Packit Service |
99d393 |
cdef class Foo:
|
|
Packit Service |
99d393 |
cdef array obj
|
|
Packit Service |
99d393 |
|
|
Packit Service |
99d393 |
######## tt.pyx ########
|
|
Packit Service |
99d393 |
|
|
Packit Service |
99d393 |
cdef class Foo:
|
|
Packit Service |
99d393 |
def __init__(self, data):
|
|
Packit Service |
99d393 |
self.obj = data
|
|
Packit Service |
99d393 |
|
|
Packit Service |
99d393 |
######## ttt.pyx ########
|
|
Packit Service |
99d393 |
|
|
Packit Service |
99d393 |
from array import array
|
|
Packit Service |
99d393 |
from cpython.array cimport array
|
|
Packit Service |
99d393 |
from tt cimport Foo
|
|
Packit Service |
99d393 |
|
|
Packit Service |
99d393 |
cdef array a = array('i', [1,2,3])
|
|
Packit Service |
99d393 |
cdef Foo x
|
|
Packit Service |
99d393 |
print a.data.as_ints[0]
|
|
Packit Service |
99d393 |
x = Foo(a)
|
|
Packit Service |
99d393 |
print x.obj.data.as_ints[0]
|