Direct Disk Reads #6615
-
Is there a way to use the Image.open API call with the O_DIRECT flag? I'm working on a project with application caching and I want to prevent all file-backed pages to load into the page cache (wasteful memory in my case) while calling the Image.open API . Let me know where I could modify the code-base to add this specific feature, if possible. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
If you look at the source code for Line 3050 in 65c832d the first parameter determines how the file is opened. Lines 3060 to 3063 in 65c832d If it is a filename, then Python is used to open the file, otherwise the file object passed in is used for subsequent read operations. Lines 3099 to 3109 in 65c832d See also https://pillow.readthedocs.io/en/stable/handbook/tutorial.html#reading-from-an-open-file So I suspect you don't need to modify Pillow - you just need to open your file with |
Beta Was this translation helpful? Give feedback.
If you look at the source code for
Image.open
,Pillow/src/PIL/Image.py
Line 3050 in 65c832d
the first parameter determines how the file is opened.
Pillow/src/PIL/Image.py
Lines 3060 to 3063 in 65c832d
If it is a filename, then Python is used to open the file, otherwise the file object passed in is used for subsequent read operations.
Pillow/src/PIL/Image.py
Lines 3099 to 3109 in 65c832d