How to apply all transformations to an object at low level? I am new to Blender (and to some extent to python). 
I have pieced together this function that rotates and scales an Object at low level by modifying the matrices: 

def rotate_scale_object(inObj, angle, axis, scaling):
        rot_mat = Matrix.Rotation(radians(angle), 4, axis)
        orig_loc, orig_rot, orig_scale = inObj.matrix_world.decompose()
        orig_loc_mat   = Matrix.Translation(orig_loc)
        orig_rot_mat   = orig_rot.to_matrix().to_4x4()
        orig_scale_mat = (Matrix.Scale(scaling,4,(1,0,0)) @ Matrix.Scale(scaling,4,(0,1,0)) @ Matrix.Scale(scaling,4,(0,0,1)))
        # assemble the new matrix
        inObj.matrix_world = orig_loc_mat @ rot_mat @ orig_rot_mat @ orig_scale_mat
        #update_matrices(inObj)
        return inObj


I call it in my script as follow:

obj = bpy.context.active_object
obj = scale_rotate_smooth_color(obj, angle = -90, axis = "X", scaling = 0.01)


It works very well: the object is rotated &amp; scaled as expected. 
Yet, I am missing a way to "apply" these transformations to the object, as one would do by pressing Ctrl + A and select Apply all transformations.

Is there a way to do this "low level", without resorting to bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)?
Mesh transform

# transform the mesh using the matrix world
ob.data.transform(ob.matrix_world)
# then reset matrix to identity

ob.matrix_world = Matrix()


Recent answer where I used Mesh.transform Problem with rotating objects by script