You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HI,
I want to create another array in C++ by using threads from python11.
Even though import object containing the array has been deleted, it remains.
However imported object was deleted, keep array in C++(following codes).
How can I create another array with using threads?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
HI,
I want to create another array in C++ by using threads from python11.
Even though import object containing the array has been deleted, it remains.
However imported object was deleted, keep array in C++(following codes).
How can I create another array with using threads?
[Cpp Codes (main.cpp)]
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pybind11/numpy.h>
std::vector CreateArray(int a);
std::vector _array(0);
std::vector CreateArray(int a)
{
_array.push_back(a);
return _array;
}
PYBIND11_MODULE(arrayproc, m) {
m.doc() = "pybind11 example";
m.def("CreateArray", &CreateArray, "");
}
[Python Codes (main.py)]
import threading
if name == 'main':
import arrayproc as test1
list1 = test1.CreateArray(1)
del(test1)
import arrayproc as test2
list2 = test2.CreateArray(1)
[Compile Texts]
gcc -O3 -Wall -shared -std=c++11 -fPIC
python3 -m pybind11 --includes
main.cpp -o arrayprocpython3-config --extension-suffix
best regards,
Beta Was this translation helpful? Give feedback.
All reactions