--- id: scandir version: "1.10.0" license: New BSD License license_treatment: permissive maintenance: abandoned --- # scandir — scandir, a better directory iterator and faster os.walk() License: permissive · Maintenance: abandoned · Downloads: 2.3M/mo ## 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 above — verify before relying. Provides faster directory iteration and os.walk() replacement by yielding DirEntry objects with cached file type and stat information, avoiding redundant system calls. 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 pip install scandir uv add scandir poetry add scandir ## Installing scandir 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+. 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) Requires a C compiler on non-Windows platforms to build the extension; prebuilt wheels available for Windows and common CPython versions. 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: unspecified - Install friction: medium - Maintenance: abandoned - Downloads: 2.3M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags fast directory iteration, os.walk replacement, directory scanning performance, DirEntry objects, efficient os.listdir, reduce stat calls, filesystem traversal, filesystem, legacy-python, performance [View on SkillFed](https://skillfed.io/packages/scandir) · [View on PyPI](https://pypi.org/project/scandir/)