How to use the cython.returns function in Cython

To help you get started, we’ve selected a few Cython examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cython / cython / tests / run / pure_py.py View on Github external
@cython.returns(cython.double)
def cdef_inline(x):
    return x + 1
github cython / cython / tests / run / pure_py.py View on Github external
@cython.returns(cython.double)
def c_call(x):
    return x
github cython / cython / tests / run / pure_py.py View on Github external
@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
github cython / cython / tests / run / pure_py.py View on Github external
@cython.returns(cython.long)
@cython.exceptval(-1)
def cdef_except(x):
    if x == 0:
        raise ValueError
    return x+1
github cython / cython / tests / run / pure_py.py View on Github external
@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
github cython / cython / tests / errors / pure_errors.py View on Github external
@cython.returns(cython.int)
def cdef_needs_gil(x):
    return x + 1
github cython / cython / tests / errors / pure_errors.py View on Github external
@cython.returns(cython.int)
def cdef_nogil(x):
    return x + 1
github man-group / mdf / mdf / nodes.py View on Github external
@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