File: c_directives.pyx

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 (43 lines) | stat: -rw-r--r-- 983 bytes parent folder | download
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
36
37
38
39
40
41
42
43
# mode: compile
# cython: boundscheck  =  False
# cython: ignoreme = OK
# cython: warn.undeclared = False
# cython: test_assert_c_code_has = Generated by Cython
# cython: test_fail_if_c_code_has = Generated by Python

# This testcase is most useful if you inspect the generated C file

print 3

cimport cython as cy

def e(object[int, ndim=2] buf):
    print buf[3, 2] # no bc

@cy.boundscheck(False)
def f(object[int, ndim=2] buf):
    print buf[3, 2] # no bc

@cy.boundscheck(True)
def g(object[int, ndim=2] buf):
    # The below line should have no meaning
# cython: boundscheck = False
    # even if the above line doesn't follow indentation.
    print buf[3, 2] # bc

def h(object[int, ndim=2] buf):
    print buf[3, 2] # no bc
    with cy.boundscheck(True):
        print buf[3,2] # bc

from cython cimport boundscheck as bc

def i(object[int] buf):
    with bc(True):
        print buf[3] # bs

from cython cimport warn as my_warn

@my_warn(undeclared=True)
def j():
    pass