foreach_get/set a mesh vertex group data? I'm searching how to batch set/get vertex group data inside blender.
using foreach_get() foreach_set() function from bpy.data.objects[0].data.vertices &amp; numpy for a fast calculation.
but it seem that those two function only accept really simple properties? and batch actions on vertex_groups/vcol are not possible in blender ?
this code below is throwing me errors
vertices[...]' elements have no attribute 'groups[0].weight'
but this error message is False the elements does have this attribute !!

note that this error message also occur with getattr() and setattr()
import bpy
import numpy as np

def print_weight(o, vg_name, use_modifiers=True):
    
    #eval object modifiers to mesh?
    if use_modifiers:
          depsgraph = bpy.context.evaluated_depsgraph_get()
          eo = o.evaluated_get(depsgraph)
          ob = eo.to_mesh(preserve_all_data_layers=True, depsgraph=depsgraph)
    else: ob = o.data
        
    &quot;&quot;&quot; 
    #slow method
    weight_values = []
    for v in ob.vertices:
        weight_values.append( v.groups[o.vertex_groups[vg_name].index].weight )
    &quot;&quot;&quot;
    #trying fast batch_get method, unsuccessful..
    weight_values = np.zeros((len(ob.vertices) * 3), dtype=np.float, )
    i = o.vertex_groups[vg_name].index
    ob.vertices.foreach_get(f&quot;groups[{i}].weight&quot;, weight_values, )

    print(weight_values)
    return

    
    
print_weight(bpy.context.object,&quot;Group&quot;)
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