scandir
scandir, a better directory iterator and faster os.walk()
Decision gist · record as of 2026-08-14
No, unless you are stuck on Python 2.7 or 3.4 and cannot upgrade. The package is abandoned (last release 2019, repository archived), and Python 3.5+ includes os.scandir() in the standard library. If you are on a modern Python version, use os.scandir() directly. If you must support legacy Python, this package works but will receive no updates.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires a C compiler on non-Windows platforms to build the extension; prebuilt wheels available for Windows and common CPython versions.
- Medium install friction due to compiled C extension (wheels provided for Python 2.7 and 3.4–3.7 on Windows).
- Repository is archived and last release was in 2019; this package is effectively superseded by os.scandir() in Python 3.5+.
License · maintenance · safety
New BSD License (permissive) — New BSD License (permissive) allows commercial and private use with minimal restrictions, making it safe for most projects.
last release 2019-03-09 (2715 days) · last repo commit 2025-05-27 · 538 stars · archived
0 known vulnerabilities (OSV.dev, 2026-08-14) · 2,332,754 downloads/mo, #3,131 on PyPI
Alternatives
Verify before relying
pip install scandir
try:
from os import scandir
except ImportError:
from scandir import scandir
for entry in scandir('.'):
if entry.is_file():
print(entry.name)- Whether the package still builds cleanly on modern Python versions beyond 3.7.
- Performance gains relative to os.scandir() in Python 3.5+ (package may offer no advantage on current Python).
What it is and what it does
scandir is a backport of os.scandir() from Python 3.5+, providing a faster alternative to os.walk() and os.listdir() by returning DirEntry objects with cached file type and stat information. Instead of making separate system calls to determine whether each entry is a file or directory, it reuses data already returned by the OS, reducing overhead by roughly 2–20 times depending on platform and filesystem. The package yields results as a generator rather than a list, improving memory efficiency for large directories.
The module is intended for Python 2.7 and 3.4+, though it has been archived and is no longer maintained. On Python 3.5 and later, the built-in os.scandir() is available and should be preferred; this package exists mainly as a compatibility shim for older Python versions that are themselves now out of support.
Use it for
- Recursively walking large directory trees on Python 2.7 or 3.4 where os.scandir() is unavailable.
- Filtering files by type (directory, symlink, regular file) without extra stat() calls in legacy codebases.
- Iterating very large directories with memory constraints by using a generator instead of loading all names at once.
- Porting code from Python 3.5+ back to older Python versions while maintaining performance.
- Batch file operations (copying, deleting, analyzing) where avoiding redundant stat calls matters.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
No, unless you are stuck on Python 2.7 or 3.4 and cannot upgrade.
The package is abandoned (last release 2019, repository archived), and Python 3.5+ includes os.scandir() in the standard library. If you are on a modern Python version, use os.scandir() directly. If you must support legacy Python, this package works but will receive no updates.
Install
scandir on PyPI
Before you install
Medium install friction due to compiled C extension (wheels provided for Python 2.7 and 3.4–3.7 on Windows). Repository is archived and last release was in 2019; this package is effectively superseded by os.scandir() in Python 3.5+.
Requires a C compiler on non-Windows platforms to build the extension; prebuilt wheels available for Windows and common CPython versions.
License in practice
New BSD License (permissive) allows commercial and private use with minimal restrictions, making it safe for most projects.
Quickstart
pip install scandir
try:
from os import scandir
except ImportError:
from scandir import scandir
for entry in scandir('.'):
if entry.is_file():
print(entry.name)
Verify before relying
- Whether the package still builds cleanly on modern Python versions beyond 3.7.
- Performance gains relative to os.scandir() in Python 3.5+ (package may offer no advantage on current Python).
Package facts
| License | New BSD License permissive |
| Python support | Not specified |
| Install friction | Medium. Platform-specific wheel |
| Runtime dependencies | None |
| Maintenance | Abandoned 2,715 days since the last release |
| Last repo commit | repository archived |
| First released | |
| Downloads | 2,332,754 / month, #3,131 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: Implementation :: CPythonTopic :: System :: FilesystemsTopic :: System :: Operating System |
Evidence: scandir-1.10.0-cp27-cp27m-win32.whl; scandir-1.10.0-cp27-cp27m-win_amd64.whl; scandir-1.10.0-cp34-cp34m-win32.whl; scandir-1.10.0-cp34-cp34m-win_amd64.whl; scandir-1.10.0-cp35-cp35m-win32.whl; scandir-1.10.0-cp35-cp35m-win_amd64.whl; scandir-1.10.0-cp36-cp36m-win32.whl; scandir-1.10.0-cp36-cp36m-win_amd64.whl; scandir-1.10.0-cp37-cp37m-win32.whl; scandir-1.10.0-cp37-cp37m-win_amd64.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “fast directory iteration”
- scandirProvides faster directory iteration and os.walk() replacement by…
- rignoreProvides fast directory traversal with support for .gitignore rules…
- ccimportccimport builds Python C++ bindings on-the-fly using pybind11 and…
Give your agent the search over MCP, or paste the wish link into any chat.
More System packages
Provides a platform-independent file locking mechanism to coordinate access to files across processes and threads.
Distro provides a reliable, machine-readable API to query the Linux or BSD distribution name, version, codename, and other OS platform details, replacing Python's deprecated `platform.linux_distribution` function.
Install it if you need to detect or report the Linux/BSD distribution your code runs on.
psutil retrieves real-time information about running processes and system resources (CPU, memory, disks, network, sensors) across multiple operating systems, enabling system monitoring, process profiling, and resource management.
Pexpect spawns and controls interactive console applications by sending input and matching output patterns, automating tasks that would otherwise require manual interaction.
Provides asynchronous file I/O operations for asyncio programs, with automatic selection of the best available backend (io_uring, libaio, thread-based, or pure Python) depending on your system.
Portalocker provides cross-platform file locking with support for exclusive and shared locks, plus Redis-based distributed locks and process-aware PID file locking.
Install it if you need file or process coordination; the optional extras (pywin32, redis) are only required for specific lock types.
See also scantree · ignore-python · rignore · provide-dir · trailrunner · iterators · py-walk · jsonslicer · croniter