Set vertex normal in a stable manner with python
I found it by observing two mesh importing add-ons, but I didn't understand how exactly it worked.

What I know is that it can only affect loop normals, not face nor vertex normals (so that won't help you if you have faces with "front" and "back" part swapped)

mesh.create_normals_split()

for face in mesh.polygons:
    face.use_smooth = True  # loop normals have effect only if smooth shading ?


# &lt;set normals (mesh.loops[ ? ].normal= ? )&gt;


# create custom data to write normals correctly?
mesh.validate(clean_customdata=False)  # important to not remove loop normals here!
mesh.update()

clnors = array.array('f', [0.0] * (len(mesh.loops) * 3))
mesh.loops.foreach_get("normal", clnors)

mesh.polygons.foreach_set("use_smooth", [True] * len(mesh.polygons))

mesh.normals_split_custom_set(tuple(zip(*(iter(clnors),) * 3)))
mesh.use_auto_smooth = True
mesh.show_edge_sharp = True  # optionnal