I got a Python list which I can obtain its pointer and pass this pointer address to C++ to work on
MyPointer = TheList.as_pointer()
now I pass this address to C++ with ctypes
in C++ I can do the following:
*(float*) MyPointer = 2.0f; //for example
and the Python values will update immediatly,now the problem is:
how to extend or delete some values (like modify the list directly from C++)
as I sense these data are a std::vector how to do push_back and so on to adjust size with a fast way (as iterating in Python is pretty much SLOW)
as_pointerseems to be Blender specific as far as I can see … Anyway, a Pythonlistis not implemented as astd::vector, it’s an own data structure. You need to cast your pointer to that data type to work with it. The type is defined in the Python C API.array.array('d')or withnumpy.arrayanyway. They allow efficient packing of floating-point numbers into the array. A Python list, on the other hand, contains (in C++ terminology) pointers to stack-allocated objects, each of which contains a single double. I.e. it's like anstd::vector<PyObject*>, where eachPyObject*must be dereferenced to get to the underlyingdouble. To append to a single number to a Python list, you must heap-allocate it to get thePyObject*.