foreach_get/set a mesh vertex group data?
I'm not entirely sure if this already is possible in some way but I made a patch last year that hasn't been reviewed yet to read/write vertex weights in batches. It speeds it up by around a factor of 8x. If you really really need it (and only on your computer) you can download and compile yourself.
https://developer.blender.org/D6227