Skip to main content

Fast, Rust-powered file operations for Python

Project description

pyofiles logo

CI PyPI version Downloads Python ≥3.9 License

pyofiles

Fast, Rust-powered file operations for Python. Drop-in replacements for os.walk, os.listdir, and glob.glob -- built on parallel directory walkers for maximum speed.

Install

uv add pyofiles

or with pip:

pip install pyofiles

CLI

pyofiles includes a command-line interface. Run directly with uvx:

uvx pyofiles find . --ext .py --modified-after 7d

Or install globally with uv tool:

uv tool install pyofiles

Version

pyofiles --version
pyofiles -v

You can also check the version from Python:

import pyofiles
print(pyofiles.__version__)

Examples

# Walk a directory, showing only Python files
pyofiles walk ./src --ext .py --skip-hidden

# Long format: type, size, modified time, path
pyofiles walk ./src --ext .py -l

# Walk with name and size filters
pyofiles walk ./src --names main utils --min-size 0.001

# Find files by name substring
pyofiles find ./data --names report invoice --ext .pdf

# Find files modified in the last 7 days
pyofiles find ./project --ext .py --modified-after 7d

# Find files created before a specific date
pyofiles find ./logs --ext .log --created-before 2024-06-01

# Find large files modified recently
pyofiles find ./data --ext .csv --min-size 100 --modified-after 24h

# Find by size alone
pyofiles find . --min-size 500

# Glob pattern matching (with time/size filters)
pyofiles glob ./project "**/*.rs"
pyofiles glob ./project "**/*.py" --modified-after 7d --max-depth 3

# List directory contents (with filters)
pyofiles ls ./some/dir -l
pyofiles ls ./src --ext .py --skip-hidden

# Index files by stem (with time filters)
pyofiles index ./src --ext .py .pyi .pyc
pyofiles index ./src --ext .py --created-after 2024-01-01

# Disk usage analysis (with extension/time/name filters)
pyofiles du ./project --depth 2 --top 10
pyofiles du ./project --ext .py --modified-after 30d
pyofiles du ./project --names test --ext .py

# JSON output (works with all commands, pipe to jq)
pyofiles find ./src --ext .py --json
pyofiles du . --json | jq '.entries[:5]'

Time formats

Time arguments (--modified-after, --modified-before, --created-after, --created-before) accept:

Format Example Meaning
Relative duration 7d, 24h, 30m, 1w ago from now
ISO date 2024-03-15 midnight on that date
ISO datetime 2024-03-15T10:30:00 specific moment
Unix timestamp 1709251200 raw epoch seconds

Filter availability

All filters are available across commands where they make sense:

Filter walk find ls glob index du
--ext yes yes yes yes (required) yes
--names yes yes yes yes yes
--min/max-size yes yes yes yes yes yes
--skip-hidden yes yes yes yes yes yes
--max-depth yes yes yes yes
time filters yes yes yes yes yes yes

Python API

walk(directory, extensions=None, skip_hidden=False, max_depth=None, names=None, min_size_mb=None, max_size_mb=None, modified_after=None, modified_before=None, created_after=None, created_before=None)

Parallel recursive directory walk. Returns list[FileEntry].

import pyofiles

# Walk everything
entries = pyofiles.walk("/path/to/dir")

# Only Python files
entries = pyofiles.walk("/path", extensions=[".py"])

# Files modified in the last 24 hours
import time
recent = pyofiles.walk("/path", modified_after=time.time() - 86400)

# Walk with name and size filters
entries = pyofiles.walk("/path", names=["test"], min_size_mb=0.01)

for e in entries:
    if e.is_file:
        print(f"{e.name} ({e.size} bytes)")

find(directory, names=None, extensions=None, min_size_mb=None, max_size_mb=None, skip_hidden=False, max_depth=None, modified_after=None, modified_before=None, created_after=None, created_before=None)

Search for files by name substrings, extensions, size, and time. Accepts multiple substrings -- a file matches if its name contains ANY of them (case-insensitive).

# Find files containing "report" or "invoice" in the name
results = pyofiles.find("/data", names=["report", "invoice"])

# Find large videos
results = pyofiles.find("/media", extensions=[".mp4", ".avi"], min_size_mb=100)

# Combine: name + extension + size
results = pyofiles.find("/docs", names=["2024"], extensions=[".pdf"], max_size_mb=50)

# Find recently modified Python files
results = pyofiles.find("/src", extensions=[".py"], modified_after=time.time() - 7*86400)

# Find files created in a date range
results = pyofiles.find("/logs", names=["error"],
                        created_after=1709251200, created_before=1711929600)

# Find by size alone
results = pyofiles.find("/data", min_size_mb=500)

list_dir(directory, extensions=None, names=None, min_size_mb=None, max_size_mb=None, skip_hidden=False, modified_after=None, modified_before=None, created_after=None, created_before=None)

Non-recursive single-directory listing. Returns list[FileEntry].

entries = pyofiles.list_dir("/path")

# List only Python files, skip hidden
entries = pyofiles.list_dir("/src", extensions=[".py"], skip_hidden=True)

# List recently modified files
entries = pyofiles.list_dir("/data", modified_after=time.time() - 86400)

index(directory, extensions, skip_hidden=False, max_depth=None, names=None, min_size_mb=None, max_size_mb=None, modified_after=None, modified_before=None, created_after=None, created_before=None)

Build a file index grouped by filename stem. Useful for finding related files with different extensions.

idx = pyofiles.index("/src", extensions=[".py", ".pyi", ".pyc"])
# {"main": {".py": "/src/main.py", ".pyc": "/src/__pycache__/main.pyc"}}

# Index only recently modified files
idx = pyofiles.index("/src", extensions=[".py"], modified_after=time.time() - 7*86400)

# Index with depth limit
idx = pyofiles.index("/project", extensions=[".py"], max_depth=3)

glob(directory, pattern, skip_hidden=False, max_depth=None, min_size_mb=None, max_size_mb=None, modified_after=None, modified_before=None, created_after=None, created_before=None)

Parallel glob pattern matching. Returns list[str] of full paths.

paths = pyofiles.glob("/project", "**/*.py")
paths = pyofiles.glob("/project", "src/**/*.{rs,toml}")

# Glob with time filter
paths = pyofiles.glob("/project", "**/*.py", modified_after=time.time() - 7*86400)

# Glob with size filter
paths = pyofiles.glob("/data", "**/*.csv", min_size_mb=10)

disk_usage(directory, depth=1, top=20, skip_hidden=False, extensions=None, names=None, min_size_mb=None, max_size_mb=None, modified_after=None, modified_before=None, created_after=None, created_before=None)

Analyze disk space usage by directory. Returns a DiskUsage object.

usage = pyofiles.disk_usage("/home", depth=2, top=10)
print(f"Total: {usage.total_size_gb:.2f} GB across {usage.total_files} files")
for entry in usage.entries:
    print(f"  {entry.path}: {entry.size_mb:.1f} MB ({entry.file_count} files)")

# Disk usage for Python files only
usage = pyofiles.disk_usage("/project", extensions=[".py"])

# Disk usage of recently modified files
usage = pyofiles.disk_usage("/project", modified_after=time.time() - 30*86400)

# Disk usage of test files
usage = pyofiles.disk_usage("/project", names=["test"], extensions=[".py"])

Types

FileEntry

Returned by walk, find, list_dir.

Attribute Type
path str
name str
is_file bool
is_dir bool
size int
extension str
modified float or None
created float or None

Timestamps are unix epoch seconds. Use datetime.fromtimestamp(entry.modified) to convert. created may be None on Linux systems that don't support creation time.

SizeEntry

Returned inside DiskUsage.entries.

Attribute Type
path str
size int
file_count int
size_mb float
size_gb float

DiskUsage

Returned by disk_usage.

Attribute Type
entries list[SizeEntry]
total_size int
total_files int
total_size_mb float
total_size_gb float

Performance

Built on jwalk (parallel directory walker) and PyO3. Typically 5-50x faster than equivalent Python code, especially on large directories and network drives.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyofiles-0.5.0.tar.gz (606.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyofiles-0.5.0-cp314-cp314-macosx_11_0_arm64.whl (703.2 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pyofiles-0.5.0-cp314-cp314-macosx_10_12_x86_64.whl (786.1 kB view details)

Uploaded CPython 3.14macOS 10.12+ x86-64

pyofiles-0.5.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (833.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pyofiles-0.5.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (766.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

pyofiles-0.5.0-cp312-cp312-win_amd64.whl (731.0 kB view details)

Uploaded CPython 3.12Windows x86-64

pyofiles-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (834.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pyofiles-0.5.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (767.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

pyofiles-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (833.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pyofiles-0.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (767.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

pyofiles-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (833.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pyofiles-0.5.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (767.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

pyofiles-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (834.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pyofiles-0.5.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (768.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

File details

Details for the file pyofiles-0.5.0.tar.gz.

File metadata

  • Download URL: pyofiles-0.5.0.tar.gz
  • Upload date:
  • Size: 606.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyofiles-0.5.0.tar.gz
Algorithm Hash digest
SHA256 337011a75189b3f62254edb5b6584557a2f9693f75f980add2ecdc28c46c3bb4
MD5 2914a07c94ca571c1fe110d9980f1055
BLAKE2b-256 764282754b28aa4f40f48c8dddbad1ee743f122c9aac73b974cd16dc4efdeb66

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.5.0.tar.gz:

Publisher: release.yml on lperezmo/pyofiles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyofiles-0.5.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyofiles-0.5.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b6ff7f153ecaa342352780c96b9b20b219887ce1744d879b3c0634b80a2a3b1d
MD5 67c263b2e1a79b2bcf1bae9920014d35
BLAKE2b-256 2d4d6901e43dc259e852cb2142440d498c11fe7c8255d414555a61be1c810b1e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.5.0-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: release.yml on lperezmo/pyofiles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyofiles-0.5.0-cp314-cp314-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyofiles-0.5.0-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 be601df818c317941966fa710ae9b7cbbc3912f4baa35743891c5187695f9160
MD5 d6aa54d94fc5ce22d26043fcc30762d3
BLAKE2b-256 9474b8eb1e5db97c561a5cb4655cac10347a56118b8c99cf582d8c68decadea4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.5.0-cp314-cp314-macosx_10_12_x86_64.whl:

Publisher: release.yml on lperezmo/pyofiles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyofiles-0.5.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyofiles-0.5.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fdd433388123ae25340f451803e5dbc1610c31ab74351c07e46876fc2a176122
MD5 35d94ff40b66a66291f3ebd71964dd67
BLAKE2b-256 28ce4594f306603f81ef55d922909b922288af68f27e84bdf76c9ff5e8b674df

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.5.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on lperezmo/pyofiles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyofiles-0.5.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyofiles-0.5.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 253ad5113fb78490742963b7722f09339319b9ed9dd2f2f66ab95aec50775781
MD5 c3a816cc7b3ec4f5cdc9da1e0506e9c1
BLAKE2b-256 7a1015cce054923969ba91be53e9373b3b978d83cf8bee06c107da682ae6655c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.5.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on lperezmo/pyofiles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyofiles-0.5.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pyofiles-0.5.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 731.0 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyofiles-0.5.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 59de94a507bf1ab39d44d727f7cc0e6fc4d1cf9804cf1d3a5334c3a5d147ac19
MD5 f2fffb384a62acf28522a0c5c798c912
BLAKE2b-256 73b764ac93d3d59c0428d4ace35af3ab5421b301a6cfb93ef0ec80da58881765

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.5.0-cp312-cp312-win_amd64.whl:

Publisher: release.yml on lperezmo/pyofiles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyofiles-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyofiles-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4586a5cfcf3e67c53058fb021b77d62f20de85f7beeb4b22486899045c341834
MD5 091158b6fb0bf4c362a1b60d5a82751e
BLAKE2b-256 ee383f4b35ad59bc80ae4f1f4b806d9e8ca78c526189bcbbfa9dd87434830ba6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on lperezmo/pyofiles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyofiles-0.5.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyofiles-0.5.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 01737babba06459996365a5780b57e408fb810e720154786d4c315ee0b03913d
MD5 cb2615b0f4f39a38488c9930e07ce65b
BLAKE2b-256 7934f70e4ab93773d1df7853a7fd5adf8e6a2d934345896d7ed7330b18f568ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.5.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on lperezmo/pyofiles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyofiles-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyofiles-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 61cca7b1c54cc25edc4248fa6bd64518df37289fa3ecaf5be7d557fe15034930
MD5 f2d3ef5789c4185498b47ca5047d619f
BLAKE2b-256 4144bb8510fc58158c7b88245ad313aae40a7e471f79a53ea14f010e36050dab

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.5.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on lperezmo/pyofiles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyofiles-0.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyofiles-0.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bc310f5f92471586850abd74aaf308ad6292aa5f043d2a0888d17b0465aecd05
MD5 702054f7270d1b2a4e969d9c8fc06c07
BLAKE2b-256 70d603c171e8f2ca0bb4afe2d2f7d337727a97e24b0f0e7fe593bda9ba4c9235

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.5.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on lperezmo/pyofiles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyofiles-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyofiles-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3884fa5a827b324502ec5052431a710c63cd4023d7e777dd11c726e56311fa3f
MD5 6657d1a7a046be658a884f0ad51a7bd7
BLAKE2b-256 c6efa9598581c0d1130e76ceba70ca3d0150314f798ac74cf382991f4cb2d608

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on lperezmo/pyofiles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyofiles-0.5.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyofiles-0.5.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 03c52c37abdf1bc9cd0057924537361e9f603f5308d288cd4712d7974913a21a
MD5 b2c5c03970051f09fa63835fda60c213
BLAKE2b-256 3b0bd53c6f5c2905fa43aeef0c4dfaba3e1fee4c10547b07a08969e018fbdfcc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.5.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on lperezmo/pyofiles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyofiles-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyofiles-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 179780355c05a2f0cb997216dc54d775c0a62a05afd1926d0d4a668f9fab07f5
MD5 f422d62d48508869ecf7cb6c5278fcf8
BLAKE2b-256 ac1f7ed7854d6134169c4721500d5d2037b4b61eb82c732cbeace2295dc69450

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on lperezmo/pyofiles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyofiles-0.5.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyofiles-0.5.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b1ce6037cc2b168a4d4be9cc05c333738d3f471f7de1899f553876ab122d02ce
MD5 46ddf2c58f816eeeec9e2532e9103cdf
BLAKE2b-256 f22eb6de01bb787429168a537ab773f230f9231f427c3e2ad9adc84a89dbe3a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.5.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on lperezmo/pyofiles

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page