Skip to main content

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.

Mount as a folder (no drive letter)

Instead of a drive letter, a volume can mount at a folder path. A folder mount creates no drive letter and no volume-arrival broadcast, so — unlike a drive-letter mount — it never wakes idle disks (e.g. a backup HDD spinning up on every mount), while still being visible across integrity levels. Recommended for background/elevated services:

with memfile.Volume(size_mb=64, folder=True) as vol:
    print(vol.path)                 # e.g. C:\Users\me\AppData\Local\memfile\mounts\<id>\
    vol.write("clip.mp4", data)
# the folder is created on mount and removed on unmount

Pass folder="C:\\some\\path" to choose the location (must not already exist, or be an empty directory).

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.

Metadata

Release files for memfile 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for memfile 0.0.5
File Size Uploaded Provenance Actions
memfile-0.0.5.tar.gz 1.5 MB Without provenance Details for memfile-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for memfile 0.0.5
File Interpreter ABI Platform Actions
memfile-0.0.5-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for memfile-0.0.5-cp39-abi3-win_amd64.whl

Total release size: 3.0 MB

Release files / memfile-0.0.5.tar.gz

Download URL memfile-0.0.5.tar.gz
Size 1.5 MB
Tags Source
SHA-256 checksum
How to use checksums
7b037c66c0902aac6a76d1ce30f52f669485bad475fa986b31683a9e7bcf4804
BLAKE2b-256 checksum
How to use checksums
488cc79e6feb4afd9085edbda65a00c0f752331067fa9e15ce10292b6aa9a6a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / memfile-0.0.5-cp39-abi3-win_amd64.whl

Download URL memfile-0.0.5-cp39-abi3-win_amd64.whl
Size 1.6 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
3b4f747c8cc124862f3245d405d64b8bdafe2c8c962f289c8ebe55a62b86b83b
BLAKE2b-256 checksum
How to use checksums
67a693b6cb2ccfa2c0fba5553c22e4cf0cc31f753e66c7f57e74d47702ffb796
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Security for memfile 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page