C++ plugin to edit image

I’m trying to make a c++ and python plugin (something like texture paint tools), but it’s too slow because I have to rewrite pixel data (bpy.data.images[0].pixels) completely after every edit. How can this be fastened? Maybe I should send pointer to pixels array to c++? (c++ code is compiled as dll and loaded to python script)

Yes. LuxCore uses this approach: https://bitbucket.org/luxrender/luxrays/src/914c72ec3085ce081a27ca890da4d27116bf47f4/src/luxcore/pyluxcoreforblender.cpp?at=default&fileviewer=file-view-default#pyluxcoreforblender.cpp-78

You can also check the Cycles bindings (intern/cycles/blender/ in the Blender source code), it generally uses the same approach - the main difference is that it accesses the data directly through the C++ RNA API instead of going through Python (which also accesses the RNA).