What is the meaning of angle brackets in Python?

后端 未结 2 1782
一生所求
一生所求 2021-02-14 19:33

I found the following lines in the scikit-learn package:

if is_sparse:
    problem = csr_set_problem(
            (

        
相关标签:
2条回答
  • 2021-02-14 19:56

    That is Cython's syntax for type casting/coercion. It is not plain Python. Notice the file extension is .pyx

    You can learn more about them in the documentation for Cython.

    Here's an example taken from the doc page:

    cdef char *p, float *q
    p = <char*>q
    

    Using Cython is not uncommon with projects like scikit-learn, where one gains significant optimisations by mixing readable Python with blazing-speed C.

    0 讨论(0)
  • 2021-02-14 20:02

    Take a look at Cython documentation, about types.

    Additionally you could note that the file extension is .pyx and on the top of the file there are cimport statements.

    0 讨论(0)
提交回复
热议问题