Easy RAM disk for Windows: instant in-memory volumes with real file paths, backed by WinFsp.
Project description
memfile
Easy RAM disk for Windows. Create an arbitrarily-sized in-memory volume in milliseconds and get a real Windows file path inside it that any application (VLC, Photos, ImageGlass, Audacity, Python, anything) can read and write.
Backed by WinFsp via a native Rust PyO3 extension.
Why
Sometimes you need a file to exist on the filesystem, ONLY because some other app
simply doesn't have the ability to open it from a memory location. If you want to write a script or an executable temporarily simply to execute it and then delete it, this is perfect. If you want easy media previews, like images, videos, and support all file formats, this is perfect, just write to the ram disk and have the OS open it in whatever is the default media viewer. Writing any of that to disk both wastes valuable SSD writes AND wastes time since ram is much much faster to write and read from. memfile gives you a real path backed entirely by RAM:
import memfile
with memfile.Volume(size_mb=64) as vol:
path = vol.write("clip.mp4", data) # real path like R:\clip.mp4
os.startfile(path) # opens in the native player
# volume + its contents vanish on exit — zero disk writes
A Volume doesn't need a with block — a bare one lives like a bare open(),
until you .unmount() it, drop it, or the process exits (it's auto-reclaimed
on exit, even on a hard kill):
vol = memfile.Volume(size_mb=128) # stays mounted
...
vol.unmount() # or just let the process end
Temp files on RAM
Drop-in replacements for the tempfile functions that put the file on a RAM
disk instead of the on-disk system temp dir — same arguments, same return
objects:
import memfile, subprocess, sys, os
with memfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f:
f.write("print('hello from RAM')")
script = f.name # e.g. R:\tmpabcd.py — in RAM
subprocess.run([sys.executable, script])
os.remove(script)
Also memfile.TemporaryFile, mkstemp, mkdtemp, TemporaryDirectory.
Requirements
- Windows (x64)
- WinFsp (installed automatically) (one-time, requires admin once). After that, creating and destroying volumes needs no elevation.
Installation
pip install memfile
License
memfile is licensed under the MIT License (see LICENSE).
It links the WinFsp DLL at runtime under the terms of the WinFsp FLOSS License Exception:
WinFsp - Windows File System Proxy, Copyright (C) Bill Zissimopoulos. https://github.com/winfsp/winfsp
WinFsp is a separate work (GPLv3 with a FLOSS exception) and must be installed
separately by the end user. memfile does not redistribute or modify WinFsp.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file memfile-0.0.4.tar.gz.
File metadata
- Download URL: memfile-0.0.4.tar.gz
- Upload date:
- Size: 1.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbfabe7383f7597659213d3052b810401c4feda88daec247e058fddcf47ae0d7
|
|
| MD5 |
774eb6909c959edf5d3e7e113fdd81b2
|
|
| BLAKE2b-256 |
ce1b6fdaaa2f71c7d1886f55ae17db79a2be922806fe77bddd244110072104c5
|
File details
Details for the file memfile-0.0.4-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: memfile-0.0.4-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e98dc19f876ad11a0cb4eee5d402fa53fd0a84e2e45ca822bc70306da0ddb33
|
|
| MD5 |
ac95033a2c2d9209141d5df0f737b439
|
|
| BLAKE2b-256 |
2edd80a88526870eef9cd8edba1f45654e65eca14e34bfc67bee6306b7504610
|