I want to load an image file into memory
In Delphi language there is a class named TMemoryStream that you can use to load some data to memory, how I should use something like MemoryStream in Python language ?
Having a quick look at TMemoryStream in the Delphi docs, it looks like the class is about producing a block of memory that is enhanced with file-like IO operators.
The equivalent class in Python can be found in the StringIO module: https://docs.python.org/2/library/stringio.html
(c)StringIO is not strictly a block of memory, as Python doesn't really expose raw memory as a concept. It can however be used to implement files in RAM, for example, creating an image file as a string for PIL (or Pillow), and then write it out to a browser as part of a CGI script. https://stackoverflow.com/a/41501060/7811466
mmapmodule maybe? - kindall