I am using the following code to try to work with C++ vectors:
from libcpp.vector cimport vector
cdef struct StartEnd:
long start, end
cdef vector[StartEnd] vect
print(type(vect))
cdef int i
cdef StartEnd j
k = {}
k['hi'] = vect
for i in range(10):
j.start = i
j.end = i + 2
k['hi'].push_back(j)
for i in range(10):
print(k['hi'][i])
The exact functionality here isn't important, this is just a dummy program. The issue is that running this generates the error: AttributeError: 'list' object has no attribute 'push_back'
This works if there is no dictionary, but I think that the dictionary is necessary for my use case. Is there a way to make this work?
I do not want to be copying vectors back and forth as these vectors will get to be tens of millions of entries long. Maybe I can store pointers to the vector instead?