I have some verticies selected (for example vtx[0] from total 9), but try to select some others using "foreach_set". So, I create an array (...here with 8 times "False", except vtx[8] is "True") and "throw" it on the mesh:
oa = bpy.context.active_object
bpy.ops.object.mode_set(mode='OBJECT')
sl = np.zeros(9, dtype=np.int32)
sl[8] = 1
### added after @lemon comment ###
setE = np.zeros(len(oa.data.edges), dtype=np.bool)
setF = np.zeros(len(oa.data.polygons), dtype=np.bool)
oa.data.polygons.foreach_set("select", setF.ravel())
oa.data.edges.foreach_set("select", setE.ravel())
##################################
oa.data.vertices.foreach_set("select", sl.ravel())
oa.data.update()
bpy.ops.object.mode_set(mode='EDIT')
I end up with vtx[0] and [8] selected. Shouldn't "False" deselect the first vertex?