I have a file that's a big binary blob, and I'm writing an editor for that file. I want to make changes, but don't want them written to disk right away; I want the option of throwing them away without saving them.
What's a good way to do this?
Some things I thought of:
- Slurp the whole file into memory and edit it there. (What if the file is huge though?)
- Make a temp file and edit that. (Same problem)
- Make a file-like object that writes to an internal data structure that sits "in front of" the file.
#3 sounds like it would work. It also sounds like something someone has probably already done, and I just don't know the right search terms to plug into google.
I'm working in Python 3.