cython
-
Cython: QuickSort code컴퓨터/파이썬 2023. 1. 1. 21:40
cimport: This directive is used to import a Cython-level version of the numpy module. ctypedef: This directive is used to define a Cython type alias for numpy.int_t. cdef: This directive is used to define a Cython function or variable. Cython functions and variables are compiled to C and are not accessible from Python. nogil: This decorator is used to indicate that a Cython function does not nee..
-
Cython을 이용한 Bubble Sort컴퓨터/파이썬 2020. 10. 24. 19:43
문법 1. bint 타입으로 bool을 이용할 수 있음. cdef bint swapped = False 2. len(array)는 Py_ssize_t를 return함. // C에서 len(array) - 1 을 구하는 과정 if (unlikely(__pyx_v_array == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 10, __pyx_L1_error) } __pyx_t_1 = PyList_GET_SIZE(__pyx_v_array); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 10, __pyx_L1_error..