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.4.0.tar.gz (604.1 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.4.0-cp314-cp314-macosx_11_0_arm64.whl (861.3 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pyofiles-0.4.0-cp314-cp314-macosx_10_12_x86_64.whl (917.2 kB view details)

Uploaded CPython 3.14macOS 10.12+ x86-64

pyofiles-0.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (993.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pyofiles-0.4.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (944.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

pyofiles-0.4.0-cp312-cp312-win_amd64.whl (758.1 kB view details)

Uploaded CPython 3.12Windows x86-64

pyofiles-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (994.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pyofiles-0.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (944.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

pyofiles-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (996.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pyofiles-0.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (947.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

pyofiles-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (996.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pyofiles-0.4.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (947.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

pyofiles-0.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (998.3 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pyofiles-0.4.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (949.0 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

File details

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

File metadata

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

File hashes

Hashes for pyofiles-0.4.0.tar.gz
Algorithm Hash digest
SHA256 d2d18921fe68b33d8576b3488e8a32c114b63d55bb0029c87241c315440117d1
MD5 eb3f3204caed3de27ad2f739a0d955ac
BLAKE2b-256 36d8abc7b092c118794b24bac3883092a6f771ec5a21962e600e5d2351bae838

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.4.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.4.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyofiles-0.4.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1f742a465ff2032cdf086f758fdeda10aa183c6e5a4876ef5788d0add3cd2c16
MD5 cc53066dc047a0e57b18b8150f8a9303
BLAKE2b-256 b1d38d8a19a40be369560c334c6ae003e6a94a25dfa45b102ca4513fd3fb982d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.4.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.4.0-cp314-cp314-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyofiles-0.4.0-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 65334bf022852444ec5c1844c31b9678099ec2a3428576d2264a5e1256194604
MD5 d49023615cfb453fde02ac3db027e689
BLAKE2b-256 b4239299548726acc9a2a17558403e2db122c37b75326f2eb2b98c031f36f398

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.4.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.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyofiles-0.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 67e76ef1e5a547f11765472ce4d871946f79fcc9c042d1982c66d6b4c6f89c54
MD5 d69ae198c8a021b32a53a50390470c58
BLAKE2b-256 1b16c1b5b043240793fd22ba77a885918310f2fad3be2930ee1359fc0f732b35

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.4.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.4.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyofiles-0.4.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f7dbc5bedfce071023163a4619188d555b773194229acb052f6f000605be091a
MD5 7af738620f8e4ca1ed266d0361eeabf2
BLAKE2b-256 0bdff92219439def960401eb1c8358729b9e4bf69bd81c6ea464c11a92836c2a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.4.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.4.0-cp312-cp312-win_amd64.whl.

File metadata

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

File hashes

Hashes for pyofiles-0.4.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9073491f7585e08b41938096945415ccb0b9ec0a2bfd4cbf4f1c81fb307a5b11
MD5 99fd41d08805ddc3b4148854d119ce5c
BLAKE2b-256 15fa02415e372b3dbb25cf8908e8491e27a163ff5f304748e89cc7cea8beedcd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.4.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.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyofiles-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4f167b83b5a32148b0bbfa1ea94f142b1483a601138626ff499afa327d042ed2
MD5 f1138bf34754c339bda9b8a3984a9e99
BLAKE2b-256 5a97853cbe038bf187d82a136d2ccc93d438aa8933cecb670f706f514f56dc90

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.4.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.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyofiles-0.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7ab1fc0e1a65800a8b0bfca42dc93d0100c5320f2c871f75d22ec611074d22eb
MD5 8f149793c76849e4af10bc64c7c89f9b
BLAKE2b-256 55d03fdde3e995019b7038b70fa025e42f2d63222ac87b37ebbb38b93a6ef770

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.4.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.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyofiles-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 186c5d400e5e147d08639f9b428b800525e821d6b478b22c665b9181643106de
MD5 732cedb6596ed2a245484802c314f4ad
BLAKE2b-256 8481eee5d673a0294a04b41e08131e899c13244743051c77a8d6ea30c13707d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.4.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.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyofiles-0.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 968a9d5c9b99d22e65983ea88dd2415c4d2a37fa77ca44de795f5ca894e3772a
MD5 92af0ae2097ccbeea380fee93b4cb853
BLAKE2b-256 3063993a59e7e5826f3e016b74f2cab35e17ad7f414498ee0931454b12391214

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.4.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.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyofiles-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5255f5fcb31e8865b3a7640d3fb032f023457b9cd86b75094d9ec023c7bd8a8f
MD5 4d7280754b29f9b4802f7ce19115bb51
BLAKE2b-256 091fe407c0ee90074379be3ce8562ebe908f5d819e2c9fe054480ba4e5d535a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.4.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.4.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyofiles-0.4.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 696cb95cd45399a0aec9394e54b5c3093023e2d3b4d44707d41eccfcc49379ef
MD5 e9829808cdd412354eed0511a95843a1
BLAKE2b-256 8360301fd61fdd270de8c5dfb7fe55430ecd7f040d16f051b81355ce13c8f047

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.4.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.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyofiles-0.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d06ed3ef4575556397e9cc65dce4d805f23ad794b9a8c47e7766f02d9c0c17bd
MD5 8ecbe5dd93ce100b6ef55b344ffd8275
BLAKE2b-256 b7f2593e2d14cca6968df665968618ad95d50ad793ef5988d4db0ff1308b9c18

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.4.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.4.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyofiles-0.4.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d9dab4d9a2ac17f240b77832704a47fe0f030b930fc3507b1e5c14b2f5181fa2
MD5 2fae54ff7b697da0f36f5ddd9042a71d
BLAKE2b-256 b4fd0641ad683b8a871dea43a1635af01f97b526095ebc71a1af8f76f8089cb4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyofiles-0.4.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