# How to set objects , or vertex point in a bezier resolution_u vertex?

I'm trying to approach the beziers, but I'm still not able to understand the situations, so I based myself on a part of this code coming from Getting the list of points that describe a Curve without converting to mesh

In this case as a test I am trying to place a series of cubes in the positions of resolution_u, without success, since when I modify the bezier, the points are always the same, in addition they do not match with the global space, I am not sure that they should be converted with a matrix operation, I don't understand how. In addition I would like to take into account the rotation of these points, so that the cubes actually follow the trend of the curve with the related twists

import bpy ,bmesh ,mathutils

spline = bpy.data.curves[0].splines[0]

if len(spline.bezier_points) >= 2:
r = spline.resolution_u + 1
segments = len(spline.bezier_points)
if not spline.use_cyclic_u:
segments -= 1

points = []
for i in range(segments):
inext = (i + 1) % len(spline.bezier_points)

knot1 = spline.bezier_points[i].co
handle1 = spline.bezier_points[i].handle_right
handle2 = spline.bezier_points[inext].handle_left
knot2 = spline.bezier_points[inext].co

_points = mathutils.geometry.interpolate_bezier(knot1, handle1, handle2, knot2, r)
points.extend(_points)

for v in points:

mesh = bpy.data.meshes.new('Cube')
cube = bpy.data.objects.new('Cube', mesh)
bm = bmesh.new()
bmesh.ops.create_cube(bm, size=0.1)
bm.to_mesh(mesh)
bm.free()