scandir is a Python library that provides a faster directory iterator and a faster `os.walk()` implementation than the standard library's `os.listdir()` and `os.walk()` for older Python versions. It backported the functionality that was later added to Python 3.5 as `os.scandir`. The current version is 1.10.0, with releases occurring infrequently as new Python versions are supported or critical fixes are needed.
pip install scandirVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `scandir.scandir()` to iterate over directory entries efficiently and `scandir.walk()` for a faster directory tree traversal, similar to `os.walk()`.
Upgrade to Python 3.4+ or Python 2.7 if using older `scandir` versions, or pin `scandir<1.10.0` for Python 2.6/3.x < 3.4 environments.
For Python 3.5+, prefer `import os` and use `os.scandir()` and `os.walk()`. Only use the `scandir` library if targeting older Python versions or if profiling shows a significant performance gain from its C extension.
Ensure the C extension is successfully built during installation if maximum performance is critical. Check installation logs for C extension build warnings.
Review code that uses `st_atime`, `st_mtime`, `st_ctime` from `DirEntry.stat()` to ensure it handles float values correctly. Cast to `int` if integer timestamps are strictly required.
Ensure you are on the latest `scandir` version. If problems persist, thoroughly test unicode path handling on your target OS and Python version, paying close attention to file system encoding settings.
No dependency data recorded yet.