Templated STL containers as argument to function in cython
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Dreamlands
--
Chapters
00:00 Question
01:01 Accepted answer (Score 2)
01:26 Thank you
--
Full question
https://stackoverflow.com/questions/1328...
Accepted answer links:
[Fused Types]: http://docs.cython.org/src/userguide/fus...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #cython
#avk47
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Dreamlands
--
Chapters
00:00 Question
01:01 Accepted answer (Score 2)
01:26 Thank you
--
Full question
https://stackoverflow.com/questions/1328...
Accepted answer links:
[Fused Types]: http://docs.cython.org/src/userguide/fus...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #cython
#avk47
ACCEPTED ANSWER
Score 2
Use Fused Types.
Example:
cimport cython
ctypedef fused any:
string
cython.int
cpdef bool is_in_vector(string a, vector[any] v)
Or this way:
ctypedef fused vector_t:
vector[string]
vector[cython.int]
cpdef bool is_in_vector(string a, vector_t v)