File: memoryview_inline_pxd.srctree

package info (click to toggle)
cython 3.0.11%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 19,092 kB
  • sloc: python: 83,539; ansic: 18,831; cpp: 1,402; xml: 1,031; javascript: 511; makefile: 403; sh: 204; sed: 11
file content (35 lines) | stat: -rw-r--r-- 891 bytes parent folder | download | duplicates (3)
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
# ticket: 1415

# Utility code from an inline function in a pxd file was not
# correctly included in a pyx file that cimported it.
# Do not add more to this test - it is intentionally minimal
# to avoid including the utility code through other means

PYTHON setup.py build_ext --inplace
PYTHON -c "import uses_inline; uses_inline.main()"

######## setup.py ########

from distutils.core import setup
from Cython.Distutils import build_ext
from Cython.Distutils.extension import Extension

setup(
    ext_modules = [
        Extension("uses_inline", ["uses_inline.pyx"]),
    ],
    cmdclass={'build_ext': build_ext},
)

######## has_inline.pxd ########

from libc.stdlib cimport malloc
cdef inline double[::1] mview(size_t size):
    return <double[:size:1]>malloc(size * sizeof(double))
    
######## uses_inline.pyx ########

from has_inline cimport mview
def main():
    return mview(1)