Idiomatic way to do list/dict in Cython?

后端 未结 6 2159
别那么骄傲
别那么骄傲 2020-12-23 17:00

My problem: I\'ve found that processing large data sets with raw C++ using the STL map and vector can often be considerably faster (and with lower memory footprint) than usi

6条回答
  •  清酒与你
    2020-12-23 17:23

    Cython now has template support, and comes with declarations for some of the STL containers.

    See http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html#standard-library

    Here's the example they give:

    from libcpp.vector cimport vector
    
    cdef vector[int] vect
    cdef int i
    for i in range(10):
        vect.push_back(i)
    for i in range(10):
        print vect[i]
    

提交回复
热议问题