pyfs_watcher
Rust-powered filesystem toolkit for Python. Fast recursive directory listing, parallel file hashing, bulk copy/move with progress, cross-platform file watching, file deduplication, content search, directory diff/sync, snapshots, disk usage, and batch rename.
Install
pip install pyfs_watcher
From source:
pip install maturin
maturin develop
Usage
Walk directories (parallel, faster than os.walk)
import pyfs_watcher
# Streaming iterator
for entry in pyfs_watcher.walk("/data", file_type="file", glob_pattern="*.py"):
print(entry.path, entry.file_size)
# Bulk collect (faster when you need all results)
entries = pyfs_watcher.walk_collect("/data", max_depth=3, sort=True, skip_hidden=True)
Hash files (parallel SHA256/BLAKE3)
# Single file
result = pyfs_watcher.hash_file("large.iso", algorithm="blake3")
print(result.hash_hex)
# Parallel batch hashing
results = pyfs_watcher.hash_files(paths, algorithm="blake3", callback=lambda r: print(r.path))
Copy/move with progress
def on_progress(p):
pct = p.bytes_copied / p.total_bytes * 100
print(f"{pct:.0f}% - {p.current_file}")
pyfs_watcher.copy_files(sources, "/dest", progress_callback=on_progress)
pyfs_watcher.move_files(sources, "/dest") # rename if same fs, copy+delete otherwise
Watch for file changes
# Sync
with pyfs_watcher.FileWatcher("/data", debounce_ms=500, ignore_patterns=["*.tmp"]) as w:
for changes in w:
for c in changes:
print(c.path, c.change_type) # "created", "modified", "deleted"
# Async
async for changes in pyfs_watcher.async_watch("/data"):
for c in changes:
print(c.path, c.change_type)
Find duplicate files
groups = pyfs_watcher.find_duplicates(
["/photos", "/backup"],
min_size=1024,
progress_callback=lambda stage, done, total: print(f"{stage}: {done}/{total}"),
)
for g in groups:
print(f"{g.file_size}B x {len(g.paths)} copies = {g.wasted_bytes}B wasted")
Search file contents (parallel regex)
# Find all files containing "TODO" in Python files
results = pyfs_watcher.search("/project", r"TODO", glob_pattern="*.py")
for r in results:
for m in r.matches:
print(f" {r.path}:{m.line_number}: {m.line_text.strip()}")
# Streaming mode
for r in pyfs_watcher.search_iter("/project", r"FIXME"):
print(r.path, r.match_count)
Compare directories
diff = pyfs_watcher.diff_dirs("/original", "/copy", detect_moves=True)
print(f"Added: {len(diff.added)}, Removed: {len(diff.removed)}, "
f"Modified: {len(diff.modified)}, Moved: {len(diff.moved)}")
Sync directories
result = pyfs_watcher.sync("/source", "/backup", delete_extra=True)
print(f"Copied: {len(result.copied)}, Deleted: {len(result.deleted)}, "
f"Skipped: {len(result.skipped)}")
# Preview changes without writing
result = pyfs_watcher.sync("/source", "/backup", dry_run=True)
Snapshot and verify file integrity
# Take a snapshot
snap = pyfs_watcher.snapshot("/important_data")
snap.save("baseline.json")
# Later, verify nothing changed
result = pyfs_watcher.verify("baseline.json")
if not result.ok:
for c in result.modified:
print(f"Modified: {c.path}")
for c in result.removed:
print(f"Removed: {c.path}")
Disk usage
usage = pyfs_watcher.disk_usage("/data")
print(f"Total: {usage.total_size:,} bytes in {usage.total_files} files")
for child in usage.children[:5]: # top 5 largest
print(f" {child.path}: {child.size:,} bytes")
Bulk rename
# Preview renames (dry_run=True by default)
result = pyfs_watcher.bulk_rename("/photos", r"IMG_(\d+)", r"photo_\1")
for entry in result.renamed:
print(f" {entry.old_name} -> {entry.new_name}")
# Apply renames
result = pyfs_watcher.bulk_rename("/photos", r"IMG_(\d+)", r"photo_\1", dry_run=False)
# Undo if needed
result.undo()
API
All functions raise typed exceptions inheriting from FsWatcherError:
WalkError- directory walk failuresHashError- hashing failuresCopyError- copy/move failuresWatchError- file watching failuresSearchError- content search failuresDirDiffError- directory diff failuresSyncError- sync failuresSnapshotError- snapshot/verify failuresDiskUsageError- disk usage failuresRenameError- bulk rename failures
Standard FileNotFoundError and PermissionError are raised for I/O errors.
Development
# Setup
uv venv && source .venv/bin/activate
uv pip install maturin pytest pytest-asyncio pytest-timeout
# Build
maturin develop
# Test
cargo test # Rust tests
pytest tests/ # Python tests
# Benchmark
python benches/bench_walk.py
python benches/bench_hash.py
Tech
- Rust + PyO3 for Python bindings
- jwalk for parallel directory traversal
- BLAKE3/SHA-256 for hashing with rayon parallelism
- notify + debouncer for cross-platform file watching
- Staged dedup pipeline: size grouping -> partial hash -> full hash
- regex crate for parallel content search
- serde/serde_json for snapshot serialization
- chrono for timestamps
Metadata
Release files for pyfs-watcher 0.3.0
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 | |
|---|---|---|---|---|
| pyfs_watcher-0.3.0.tar.gz | 253.9 kB | With provenance | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyfs_watcher-0.3.0-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details |
| pyfs_watcher-0.3.0-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details |
| pyfs_watcher-0.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.8 | CPython 3.8 | Linux glibc 2.17+ x86-64 | Details |
Total release size: 4.2 MB
Release files / pyfs_watcher-0.3.0.tar.gz
| Download URL | pyfs_watcher-0.3.0.tar.gz |
|---|---|
| Size | 253.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f7a3e365db6c8430b4056fc37c39d785aa28980fdc1449dbd678c0036608c3e5
|
|
BLAKE2b-256 checksum How to use checksums |
4fd595024ae7848ee015ad95148865b2364ef2633c88d2df39aaa6358f490819
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 4, 2026.
Transparency logRelease files / pyfs_watcher-0.3.0-cp39-abi3-win_amd64.whl
| Download URL | pyfs_watcher-0.3.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
2fa4fd944aa789b12c665bc3a68a40ec68e4dbdeb631c482f5fc3b77f842f873
|
|
BLAKE2b-256 checksum How to use checksums |
22ba49363edce6e30d8dc3cbeabef341ff8bbd435782f0083a8a8fb4fa734432
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 4, 2026.
Transparency logRelease files / pyfs_watcher-0.3.0-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | pyfs_watcher-0.3.0-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
2af2ec59d432d54daef9eff2ea675f5dfb46ae805ddbe273f31397eddff427fe
|
|
BLAKE2b-256 checksum How to use checksums |
bc048fda3451475917f141f3c288b10dcd4c3a62476fce3499f5789d16837800
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 4, 2026.
Transparency logRelease files / pyfs_watcher-0.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyfs_watcher-0.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
b4d3694d5e9d23b5df0e88814a8f1671c58fa76494f70d407abaf9a650826938
|
|
BLAKE2b-256 checksum How to use checksums |
fe9e7353d2fbe10b997b0980c6cd70a896ec85e358434599453d426dab998226
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 4, 2026.
Transparency logSecurity for pyfs-watcher 0.3.0
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.
Full provenance
All 4 files in this release have been uploaded with provenance metadata.
Attestation for pyfs_watcher-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 4, 2026.
Transparency logA 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.