How do I get the Triangulate modifiers full effect using python

In blender 2.8 the triangulate modifier has a “Keep Normals” flag (keep_custom_normals internally). How do I get this same effect of preserving the normals when triangulating using python.

I cant use the well known mesh_triangulate() method

def mesh_triangulate(me):
import bmesh
bm = bmesh.new()
bm.from_mesh(me)
bmesh.ops.triangulate(bm, faces=bm.faces, quad_method=‘FIXED’, ngon_method=‘BEAUTY’)
bm.to_mesh(me)
bm.free()

as it destroys the artists normals.

I dont want to apply the modifier to the original object because this is for an exporter and I dont want to
triangulate the original scene objects, the export should be read only.

Ive also tried copying the original object and its mesh data, setting it as the active object, adding the triangulate modifier, setting its settings, and applying it, but unless the object is linked using
bpy.context.scene.collection.objects.link(obj), i get the error

RuntimeError: Operator bpy.ops.object.modifier_add.poll() failed, context is incorrect

which I guess means the object needs to be in the scene first, but again, I dont want to modify the scene in anyway, this should be a read only operation without intruding on the artists workspace.

Is there any way to produce the “Keep Normals” effect through python on copies of the object mesh data?

You can use copy and paste buffers before and after, applying the modifier. I used it for similar purposes in the past.

Another thing you can do is to save a copy of the scene, apply modifiers and reload the copy back.

Thanks for suggestions, but to me it still feels like a work around for something that should be fully supported. A lack of easy and direct access to triangle data in a modeling package with full script support is a pretty big problem if the only solutions involve monkeying around with copies of entire scenes or firing UI callbacks that fail unless the object is in the scene.

I looked for the actual code that handles that flag, I think its this

https://developer.blender.org/diffusion/B/browse/master/source/blender/modifiers/intern/MOD_triangulate.c

does anyone know what the sections relating to “if (keep_clnors)” on lines 50,52, and 71 related to custom data are doing and if they can be accessed using python?