I'm building a specialized text editor using Tkinter Text widgets. Some of the files that will be edited are fairly large (300K-500K lines). Some of the functions in the editor affect the whole file (e.g., tagging certain lines based on content, etc.). I'm using autoseparators to handle these situations where an undo essentially resets the entire Text widget contents to the previous state. In other words, I get the entire Text widget contents, process it, and then delete the existing Text widget contents and then insert the edited contents. The problem is, memory usage could potentially be a problem. For example, a 295K line file (about 6.8MB) may cause a memory increase of about 25MB when a document-wide function is performed (not sure where the 3-4X comes from). During a session a user might execute numerous document-wide functions. 
I would at least like to "clear" the undo/redo stack when the user opens a new file or simply creates a new blank file. I know there are lots of arguments about keeping undo/redo across files, but for my user community this is not an issue. Clearing the stack would not affect their workflow.
I did try turning off the Text widget undo (via configure) and then turning it back on, but that didn't seem to have any effect. 
I would appreciate any thoughts on this question or guidance on a better approach to handling this type of situation. Thanks.
The edit_reset method clears the undo stack.
Is there a way to clear the undo/redo stack for the Text widget in Tkinter?