Python getdents
Iterate large directories efficiently with python.
About
python-getdents is a simple wrapper around Linux system call getdents64 (see man getdents for details). Here’s some study on why ls, os.listdir() and others are so slow when dealing with extremely large directories.
TODO
Verify that implementation works on platforms other than x86_64.
Add python2 support.
Install
pip install getdents
For development
python3 -m venv env
. env/bin/activate
pip install -e .
Run tests
./setup.py test
Usage
from getdents import getdents
for inode, type, name in getdents('/tmp', 32768):
print(name)
Advanced
import os
from getdents import *
fd = os.open('/tmp', O_GETDENTS)
for inode, type, name in getdents_raw(fd, 2**20):
print({
DT_BLK: 'blockdev',
DT_CHR: 'chardev ',
DT_DIR: 'dir ',
DT_FIFO: 'pipe ',
DT_LNK: 'symlink ',
DT_REG: 'file ',
DT_SOCK: 'socket ',
DT_UNKNOWN: 'unknown ',
}[type], {
True: 'd',
False: ' ',
}[inode == 0],
name,
)
os.close(fd)
Metadata
Release files for getdents 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| getdents-0.1.tar.gz | 6.2 kB | Without provenance | Details for getdents-0.1.tar.gz |
Release files / getdents-0.1.tar.gz
| Download URL | getdents-0.1.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3cc27ea1098aa2fa47d1bc45a81fa89e9eebf78ccd5f253cc79fa171e2b73843
|
|
BLAKE2b-256 checksum How to use checksums |
7da696965104f9518fce64c0fb2dddabb30867bb2d12fc209f88edbe0286b6c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for getdents 0.1
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.