To apply all transformations to an object, all its vertices must be multiplied by its global matrix, the matrix itself must be made identity.
To apply all transformations to the active mesh, we need to execute the following:
obj = bpy.context.object
matrix = obj.matrix_world.copy()
for vert in obj.data.vertices:
vert.co = matrix @ vert.co