--- id: memory-tempfile version: "2.2.3" license: MIT license_treatment: permissive maintenance: dormant --- # memory-tempfile — Helper functions to identify and use paths on the OS (Linux-only for now) where RAM-based tempfiles can be created. License: permissive · Maintenance: dormant · Downloads: 636.2K/mo ## What it is and what it does memory-tempfile wraps Python's standard tempfile module to automatically detect and use RAM-based filesystems (tmpfs, ramfs) for temporary files on Linux. Instead of writing to physical disk, it searches a prioritized list of in-memory paths—/tmp, /run/user/{uid}, /run/shm, /dev/shm—and uses the first one that exists and is backed by a memory filesystem. This avoids the I/O overhead and wear on storage media that comes from repeated temporary file creation. The package exposes a MemoryTempfile class that mirrors the standard tempfile API (TemporaryFile, NamedTemporaryFile, etc.) but with configurable path search order, filesystem type filters, and fallback behavior. You can customize which paths to search, add or exclude specific directories, and choose whether to fall back to the system default tempdir if no memory-based path is found. All path templates with {uid} are automatically replaced with the current user ID. Use it for: - Reduce I/O overhead when external tools require temporary files but you want to avoid disk writes. - Minimize storage wear in embedded or long-running systems that create many temporary files. - Speed up test suites that generate and discard temporary files repeatedly. - Work with external command-line tools that write output to disk but cannot pipe directly to your application. - Configure fallback behavior for temporary file creation in restricted or containerized environments. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Identifies and provides access to RAM-based temporary file directories on Linux, allowing you to create temporary files in memory instead of on physical disk. Yes, if you are on Linux and need to reduce I/O overhead from temporary files. The package is simple, dependency-free, and solves a specific problem well. However, it is dormant (no releases since 2020); install it only if the stable API meets your needs and you do not expect active maintenance or new features. Not suitable for non-Linux platforms. ## Install pip install memory-tempfile uv add memory-tempfile poetry add memory-tempfile ## Installing memory-tempfile Before you install: Low friction to install. The package is dormant (last release March 2020, last commit May 2024) but has no runtime dependencies and is a pure Python wheel. Suitable for stable, narrow-scope use cases; not actively maintained for new features. License in practice: MIT license is permissive; you can use this package freely in proprietary or open-source projects with minimal restrictions. Quickstart: from memory_tempfile import MemoryTempfile tempfile = MemoryTempfile() with tempfile.TemporaryFile() as tf: tf.write(b'data') Linux only; requires access to /proc/self/mountinfo. Python 3.6 or later. Verify before relying: - Whether the package correctly handles all modern tmpfs mount configurations beyond /tmp, /run/user/{uid}, /run/shm, and /dev/shm. - Performance characteristics when searching for suitable paths on systems with many mount points. - Compatibility with containerized or restricted environments beyond chroot and namespaces. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: dormant - Downloads: 636.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags ram temporary files linux, in-memory tempfile, tmpfs tempdir, ramdisk temporary storage, dev shm tempfile, fast temporary files, memory-based tempdir, linux-only, io-optimization, tempfile-management [View on SkillFed](https://skillfed.io/packages/memory-tempfile) · [View on PyPI](https://pypi.org/project/memory-tempfile/)