I'm learning about working with streams in Python and I noticed that the IO docs say the following:
The easiest way to create a binary stream is with open() with 'b' in the mode string:
f = open("myfile.jpg", "rb")
In-memory binary streams are also available as BytesIO objects:
f = io.BytesIO(b"some initial binary data: \x00\x01")
What is the difference between f
as defined by open
and f
as defined by BytesIO
. In other words, what makes a "In-memory binary stream" and how is that different from what open
does?