Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@cython.returns(cython.double)
def cdef_inline(x):
return x + 1
@cython.returns(cython.double)
def c_call(x):
return x
@cython.returns(cython.long)
@cython.exceptval(check=True)
def ccall_except_check_always(x):
"""
>>> ccall_except_check_always(41)
42
>>> ccall_except_check_always(0)
Traceback (most recent call last):
ValueError
"""
if x == 0:
raise ValueError
return x+1
@cython.returns(cython.long)
@cython.exceptval(-1)
def cdef_except(x):
if x == 0:
raise ValueError
return x+1
@cython.returns(cython.long)
@cython.exceptval(-1, check=True)
def ccall_except_check(x):
"""
>>> ccall_except_check(41)
42
>>> ccall_except_check(-2)
-1
>>> ccall_except_check(0)
Traceback (most recent call last):
ValueError
"""
if x == 0:
raise ValueError
return x+1
@cython.returns(cython.int)
def cdef_needs_gil(x):
return x + 1
@cython.returns(cython.int)
def cdef_nogil(x):
return x + 1
@cython.returns(NodeSetDirtyState)
def create_NodeSetDirtyState(depth, node_state, node, flags):
obj = cython.declare(NodeSetDirtyState)
obj = NodeSetDirtyState()
obj.depth = depth
obj.node_state = node_state
obj.node = node
obj.flags = flags
return obj