Skip to main content
Release file added late

1 file was added to this release more than 14 days after its initial publication. Inspect the release files before installing.

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). More details on approach.

TODO

  • Verify that implementation works on platforms other than x86_64.

Install

pip install getdents

For development

python3 -m venv env
. env/bin/activate
pip install -e .[test]

Run tests

ulimit -v 33554432 && py.test tests/

Or

ulimit -v 33554432 && ./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)

CLI

Usage

python-getdents [-h] [-b N] [-o NAME] PATH

Options

Option

Description

-b N

Buffer size (in bytes) to allocate when iterating over directory. Default is 32768, the same value used by glibc, you probably want to increase this value. Try starting with 16777216 (16 MiB). Best performance is achieved when buffer size rounds to size of the file system block.

--buffer-size N

-o NAME

Output format:

  • plain (default) Print only names.

  • csv Print as comma-separated values in order: inode, type, name.

  • csv-headers Same as csv, but print headers on the first line also.

  • json output as JSON array.

  • json-stream output each directory entry as single json object separated by newline.

--output-format NAME

Exit codes

  • 3 - Requested buffer is too large

  • 4 - PATH not found.

  • 5 - PATH is not a directory.

  • 6 - Not enough permissions to read contents of the PATH.

Examples

python-getdents /path/to/large/dir
python -m getdents /path/to/large/dir
python-getdents /path/to/large/dir -o csv -b 16777216 > dir.csv

Metadata

Release files for getdents 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

File added late

1 file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release files before installing.

Source distribution (sdist)

Source distribution for getdents 0.3
File Size Uploaded Provenance Actions
getdents-0.3.tar.gz 6.3 kB Without provenance Details for getdents-0.3.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for getdents 0.3
File Actions
getdents-0.3-cp38-cp38-manylinux1_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.5+ x86-64 Details for getdents-0.3-cp38-cp38-manylinux1_x86_64.whl
getdents-0.3-cp37-cp37m-manylinux1_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 Details for getdents-0.3-cp37-cp37m-manylinux1_x86_64.whl
getdents-0.3-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details for getdents-0.3-cp36-cp36m-manylinux1_x86_64.whl
getdents-0.3-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details for getdents-0.3-cp35-cp35m-manylinux1_x86_64.whl

Total release size: 99.1 kB

Release files / getdents-0.3.tar.gz

Download URL getdents-0.3.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4ba0d59a1676fb0e41d5b658ed4a20464bd57fcef1e14e51b1d9847791d982ec
BLAKE2b-256 checksum
How to use checksums
16a36e25ec614d9e891c38b632368bc636e00e10c9f728e66de78b6f42aa23bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.9

Release files / getdents-0.3-cp38-cp38-manylinux1_x86_64.whl

File added late

This file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release file before installing.

Download URL getdents-0.3-cp38-cp38-manylinux1_x86_64.whl
Size 23.0 kB
Tags CPython 3.8 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
b9c62884dc948e2522ab4a971fd82eb94f1a8c53199a66708238c845dd840669
BLAKE2b-256 checksum
How to use checksums
4c86aa75345df238da247522a3a4155403ce4fd26ae6c44d40ab661d3049bb55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.9

Release files / getdents-0.3-cp37-cp37m-manylinux1_x86_64.whl

Download URL getdents-0.3-cp37-cp37m-manylinux1_x86_64.whl
Size 24.0 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
d79deb1faed5a9e56f816ee9e88cf8ba76e86b55513c8e752a98beb58925a049
BLAKE2b-256 checksum
How to use checksums
b294078893ac2e1a148716bc8b4a6ff2bac8c2204bca1a586a32a8d0822c1327
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.9

Release files / getdents-0.3-cp36-cp36m-manylinux1_x86_64.whl

Download URL getdents-0.3-cp36-cp36m-manylinux1_x86_64.whl
Size 23.1 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
df1372c1d74fd4427230a6130e12b7c9cc5d3f4605d1d566263a0645f2ca6c52
BLAKE2b-256 checksum
How to use checksums
91ea8b0fc9684e5df59fa6d04f49ef0026474d69fcf84d98555f2df4d81307b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.9

Release files / getdents-0.3-cp35-cp35m-manylinux1_x86_64.whl

Download URL getdents-0.3-cp35-cp35m-manylinux1_x86_64.whl
Size 22.7 kB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
10fe119297be12d3e963c48f5a8e2700cc91ac310eace695e81b095daa142845
BLAKE2b-256 checksum
How to use checksums
30ae7b77c01eac5c8e6ec62a0b95891719b0a7342c46a37761304ace6eee2c77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.9

Security for getdents 0.3

Upload timing

Release file added late

1 file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.


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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page