{"id":28003918,"url":"https://github.com/zipfile/python-getdents","last_synced_at":"2025-07-28T01:35:37.860Z","repository":{"id":57433968,"uuid":"75949185","full_name":"ZipFile/python-getdents","owner":"ZipFile","description":"Python binding to Linux syscall getdents64","archived":false,"fork":false,"pushed_at":"2025-04-01T10:02:01.000Z","size":52,"stargazers_count":8,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-27T07:38:19.361Z","etag":null,"topics":["getdents64","python-library"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/getdents/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZipFile.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-08T15:19:35.000Z","updated_at":"2025-01-16T18:35:42.000Z","dependencies_parsed_at":"2024-08-11T14:43:11.212Z","dependency_job_id":"e605680c-d362-4414-ac53-c5c5dc907a4c","html_url":"https://github.com/ZipFile/python-getdents","commit_stats":{"total_commits":15,"total_committers":1,"mean_commits":15.0,"dds":0.0,"last_synced_commit":"6a9c0b3a71b91df0324790746b71e4f38fb449d0"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZipFile%2Fpython-getdents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZipFile%2Fpython-getdents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZipFile%2Fpython-getdents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZipFile%2Fpython-getdents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZipFile","download_url":"https://codeload.github.com/ZipFile/python-getdents/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253177969,"owners_count":21866426,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["getdents64","python-library"],"created_at":"2025-05-09T02:33:17.718Z","updated_at":"2025-05-09T02:33:38.970Z","avatar_url":"https://github.com/ZipFile.png","language":"Python","readme":"===============\nPython getdents\n===============\n\nIterate large directories efficiently with python.\n\nAbout\n=====\n\n``python-getdents`` is a simple wrapper around Linux system call ``getdents64`` (see ``man getdents`` for details). `More details \u003chttp://be-n.com/spw/you-can-list-a-million-files-in-a-directory-but-not-with-ls.html\u003e`_ on approach.\n\nTODO\n====\n\n* Verify that implementation works on platforms other than ``x86_64``.\n\nInstall\n=======\n\n.. code-block:: sh\n\n    pip install getdents\n\nFor development\n---------------\n\n.. code-block:: sh\n\n    python3 -m venv env\n    . env/bin/activate\n    pip install -e .[test]\n\nBuilding Wheels\n~~~~~~~~~~~~~~~\n\n.. code-block:: sh\n\n    pip install cibuildwheel\n    cibuildwheel --platform linux --output-dir wheelhouse\n\nRun tests\n=========\n\n.. code-block:: sh\n\n    ulimit -v 33554432 \u0026\u0026 py.test tests/\n\nOr\n\n.. code-block:: sh\n\n    ulimit -v 33554432 \u0026\u0026 ./setup.py test\n\nUsage\n=====\n\n.. code-block:: python\n\n    from getdents import getdents\n\n    for inode, type, name in getdents('/tmp', 32768):\n        print(name)\n\nAdvanced\n--------\n\n.. code-block:: python\n\n    import os\n    from getdents import *\n\n    fd = os.open('/tmp', O_GETDENTS)\n\n    for inode, type, name in getdents_raw(fd, 2**20):\n        print({\n                DT_BLK:     'blockdev',\n                DT_CHR:     'chardev ',\n                DT_DIR:     'dir     ',\n                DT_FIFO:    'pipe    ',\n                DT_LNK:     'symlink ',\n                DT_REG:     'file    ',\n                DT_SOCK:    'socket  ',\n                DT_UNKNOWN: 'unknown ',\n            }[type], {\n                True:  'd',\n                False: ' ',\n            }[inode == 0],\n            name,\n        )\n\n    os.close(fd)\n\nCLI\n---\n\nUsage\n~~~~~\n\n::\n\n    python-getdents [-h] [-b N] [-o NAME] PATH\n\nOptions\n~~~~~~~\n\n+--------------------------+-------------------------------------------------+\n| Option                   | Description                                     |\n+==========================+=================================================+\n| ``-b N``                 | Buffer size (in bytes) to allocate when         |\n|                          | iterating over directory. Default is 32768, the |\n|                          | same value used by glibc, you probably want to  |\n+--------------------------+ increase this value. Try starting with 16777216 |\n| ``--buffer-size N``      | (16 MiB). Best performance is achieved when     |\n|                          | buffer size rounds to size of the file system   |\n|                          | block.                                          |\n+--------------------------+-------------------------------------------------+\n| ``-o NAME``              | Output format:                                  |\n|                          |                                                 |\n|                          | * ``plain`` (default) Print only names.         |\n|                          | * ``csv`` Print as comma-separated values in    |\n+--------------------------+   order: inode, type, name.                     |\n| ``--output-format NAME`` | * ``csv-headers`` Same as ``csv``, but print    |\n|                          |   headers on the first line also.               |\n|                          | * ``json`` output as JSON array.                |\n|                          | * ``json-stream`` output each directory entry   |\n|                          |   as single json object separated by newline.   |\n+--------------------------+-------------------------------------------------+\n\nExit codes\n~~~~~~~~~~\n\n* 3 - Requested buffer is too large\n* 4 - ``PATH`` not found.\n* 5 - ``PATH`` is not a directory.\n* 6 - Not enough permissions to read contents of the ``PATH``.\n\nExamples\n~~~~~~~~\n\n.. code-block:: sh\n\n    python-getdents /path/to/large/dir\n    python -m getdents /path/to/large/dir\n    python-getdents /path/to/large/dir -o csv -b 16777216 \u003e dir.csv\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzipfile%2Fpython-getdents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzipfile%2Fpython-getdents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzipfile%2Fpython-getdents/lists"}