Undo specific steps within a script

I’m looking for a way to undo some steps while running a script. I mean specific steps within the script not the whole script.
Like:


bpy.ops.mesh.delete(type=‘VERT’)
>undo<

So far I’ve found “bpy.ops.ed.undo()” but it doesn’t seem to do what I want. Can anybody help? Thanks!