How to use the cython.ccall 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.ccall
@cython.returns(cython.double)
def c_call(x):
    return x
github cython / cython / tests / run / pure_py.py View on Github external
@cython.ccall
@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 / run / pure_py3.py View on Github external
@cython.ccall  # cpdef => C return type
def test_return_type(n: cython.int) -> cython.double:
    """
    >>> test_return_type(389)
    389.0
    """
    assert cython.typeof(n) == 'int', cython.typeof(n)
    return n if is_compiled else float(n)
github cython / cython / tests / run / pure_py3.py View on Github external
@cython.ccall
def c_call(x) -> cython.double:
    return x
github cython / cython / tests / run / pure_py.py View on Github external
@cython.ccall
@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 catboost / catboost / contrib / tools / cython / Cython / Compiler / Pythran.py View on Github external
@cython.ccall
def is_pythran_supported_type(type_):
    pythran_supported = (
        "is_pythran_expr", "is_int", "is_numeric", "is_float", "is_none", "is_complex")
    return is_type(type_, pythran_supported) or is_pythran_expr(type_)
github catboost / catboost / contrib / tools / cython / Cython / Compiler / Pythran.py View on Github external
@cython.ccall
def is_pythran_expr(type_):
    return type_.is_pythran_expr
github cython / cython / Cython / Compiler / Pythran.py View on Github external
@cython.ccall
def is_pythran_expr(type_):
    return type_.is_pythran_expr
github cython / cython / Cython / Compiler / Pythran.py View on Github external
@cython.ccall
def is_pythran_supported_type(type_):
    pythran_supported = (
        "is_pythran_expr", "is_int", "is_numeric", "is_float", "is_none", "is_complex")
    return is_type(type_, pythran_supported) or is_pythran_expr(type_)