How can I send a string to an external text editor?

  python-3.7, windows

I want to display a string to the user using an external text editor (notepad++). The string is about 100MB-1GB in size. I want to avoid writing to a temporary file and then opening it in the text editor as this involves writing the whole string to disk and then reading it from disk. I would like to minimise the delay. Can I somehow load it straight from memory into the text editor?

In linux I could write/read to tmpfs to keep it in memory but there doesn’t seem to be any equivalent in Windows. Even with tmpfs, there is an uneccesary comsumption of memory.

Ultimately something like this:

import os
with open('myfile.bin', 'rb') as f:
    whole_file: bytes = f.read()
my_str: str = process_bytes(whole_file)
os.startfile(my_str)

Source: Windows Questions

LEAVE A COMMENT