Trying to swap vertex with uv by script
Look like i'm just understand with the concept of loops in blender.

What i'm not aware is one vert can be referenced on more than one loop (and it's pretty common).

So, the solution for this is make sure that the code do not touch the same vertex index (by making a list):

def swapOnAxis (axis):
    C = bpy.context
    o = C.active_object.data
    bm = bmesh.new()
    if C.active_object.mode != 'EDIT':
        bm.from_mesh(o)
    else:
        bm.from_mesh_edit(o)

    uv_layer = None
    if 'SwappedUV' in bm.loops.layers.uv.keys():
        uv_layer = bm.loops.layers.uv['SwappedUV']
    else:
        uv_layer = bm.loops.layers.uv.new('SwappedUV')

    dict = []
    for f in bm.faces:
        for l in f.loops:
            luv = l[uv_layer]
            v = l.vert
            # make sure that we haven't do it on the same vertex
            if (v.index not in dict):
                luv.uv.x, v.co[axis] = v.co[axis], luv.uv.x
                dict.append(v.index)
            else:
                luv.uv.x = v.co[axis]

    if C.active_object.mode != 'EDIT':
        bm.to_mesh(o)
    else:
        bm.update_edit_mesh(o)

    bm.free() 
    o.update()