A fast file tree scanner written in Rust
Project description
scandir-rs
The Python module is called scandir_rs
and installable via pip
. It is an alternative to os.walk()
and os.scandir()
with more features and higher speed. On Linux it is 3 - 11 times faster and on Windows 6 - 70 time faster (see benchmarks).
It releases the GIL and the scanning is done in a background thread. With different methods intermediate results can be read.
If you are just interested in directory statistics you can use the Count
.
scandir_rs
contains following classes:
Count
for determining statistics of a directory.Walk
for getting names of directory entries.Scandir
for getting detailed stats of directory entries.
For the API see:
Installation
For building this wheel from source you need the tool maturin
.
Install maturin
:
cargo install maturin
IMPORTANT: In order to build this project at least Rust version 1.61 is needed!
Build wheel:
Change to directory pyscandir
.
Build wheel (on Linux):
maturin build --release --strip
Build wheel on Windows:
maturin build --release --strip --no-sdist
maturin
will build the wheels for all Python versions installed on your system.
Alternatively you can use the build script build_wheels.py
. The precondition to run this script is to have pyenv
installed.
The script can build the wheel for specific Python versions or for all Python versions installed by pyenv
.
In addition it runs pytest
after successfull creation of each wheel.
python build_wheels.py
By default the script will build the wheel for the current Python interpreter.
If you want to build the wheel for specific Python version(s) by providing the argument --versions
.
python build_wheels.py --versions 3.11.8,3.12.2
To build the wheel for all installed Python versions:
python build_wheels.py --versions *
Instruction how to install pyenv
can be found here.
Examples
Get statistics of a directory:
from scandir_rs import Count, ReturnType
print(Count("/usr", return_type=ReturnType.Ext).collect())
The collect
method releases the GIL. So other Python threads can run in parallel.
The same, but asynchronously in background using a class instance:
from scandir_rs import Count, ReturnType
instance = Count("/usr", return_type=ReturnType.Ext)
instance.start() # Start scanning the directory in background
...
values = instance.results() # Returns the current statistics. Can be read at any time
...
if instance.busy(): # Check if the task is still running.
...
instance.stop() # If you want to cancel the task
...
instance.join() # Wait for the instance to finish.
and with a context manager:
import time
from scandir_rs import Count, ReturnType
with Count("/usr", return_type=ReturnType.Ext) as instance:
while instance.busy():
statistics = instance.results()
# Do something
time.sleep(0.01)
print(instance.results())
os.walk()
example:
from scandir_rs import Walk
for root, dirs, files in Walk("/usr"):
# Do something
with extended data:
from scandir_rs import Walk, ReturnType
for root, dirs, files, symlinks, other, errors in Walk("/usr", return_type=ReturnType.Ext):
# Do something
os.scandir()
example:
from scandir_rs import Scandir, ReturnType
for path, entry in Scandir("~/workspace", return_type=ReturnType.Ext):
# entry is a custom DirEntry object
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for scandir_rs-2.8.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f7b2154549dbb1b10d41b52f7d87f73b70984d897d74af5589883a8f917130f |
|
MD5 | 14dde5d224a598b78f74b82a30508bf4 |
|
BLAKE2b-256 | 1793cab1951070e6118cb507b9e7ab0848f42ba6437affc476ed9bf68dded6a2 |
Hashes for scandir_rs-2.8.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2533b29b78628f9bb904d3a6f00b4bf139c25cbda2528c6b797c7ac13aa810a |
|
MD5 | fccc97b76b89cc574cfd6fc83b620b00 |
|
BLAKE2b-256 | ea56c39a6c655a413f6e40c953c281ef210026a9d8c1b6b6f8693a96bc11807e |
Hashes for scandir_rs-2.8.0-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2af72d1f183feafb1c8a7b256bc0dc0079f3a16f6192bbbb7c75c7e747934f34 |
|
MD5 | 8fd1c29fb874f0e7e5d8f0bddbb1607e |
|
BLAKE2b-256 | 1b322f5a9b72447c22d554e4b0ec8226f61f1a6dd3b3662720e4d67b5932bd90 |
Hashes for scandir_rs-2.8.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c362c1d020583e07abee2719d452f669fa6b200a88bf43e46463445cec9f3661 |
|
MD5 | fb4bad7b422fe6f23741a6251cc38f8d |
|
BLAKE2b-256 | b12a18b67f072d7ab3091eda14b001559d73b147b582e64c34dbf14cd695b315 |
Hashes for scandir_rs-2.8.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a11f36eacca96fb55e4002ebec9733de065b02d32310d74b1c50fdfb6591661 |
|
MD5 | d662dc677fadd05f7054e6af0cf04f57 |
|
BLAKE2b-256 | 0ba9c8421f4d394722cb39f29717b8d1052e20d10b640e70bd56944aecb7e966 |
Hashes for scandir_rs-2.8.0-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 406a78c7a046a721dadddb30cac460b84cd7e9284824feb8951363917145758c |
|
MD5 | 2e94509888b4988d23d2081ce9f9d01e |
|
BLAKE2b-256 | 21011a69148dcaad0640c96eca25a4602fa9d231bef99c49c82ec49e0ff9de74 |
Hashes for scandir_rs-2.8.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8bdf8fa2148c68048427c4c001d55606e68651a10dd81ad0a8e0333dc328801 |
|
MD5 | 45e83025c55575296628741f4aa72ae5 |
|
BLAKE2b-256 | bbfcdb3aed3e1e287861c2cfff69688ff45c80bb621ee8a8bb0f4e164f82cabc |
Hashes for scandir_rs-2.8.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42bb78716f4a7d5cafe27fbb2e03f42e6ca8f07c5103c32f9d82da70e584a619 |
|
MD5 | 7d5f4aa396698bad703f4c97979b723f |
|
BLAKE2b-256 | 411e17b9742d118f68106002cd12981ddf52ab413ae9bcc04a33da7bb47681ad |
Hashes for scandir_rs-2.8.0-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92c4c4733751dc68368ea615a59d61e22b789427e8afcb11f521eaeceeff09bb |
|
MD5 | 92f04886d2672cb95700e39201c7aecf |
|
BLAKE2b-256 | 21fda9cbc497b09c77e0557e53a424cda1baf60b65eafd0b6a78a876516cdaef |
Hashes for scandir_rs-2.8.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c749ab3d2a0aa90fa0f69ef433eb0d08e4f2c290929290ae9adab33964e12a46 |
|
MD5 | e06a7d757877e953aaf3d3b60bc13623 |
|
BLAKE2b-256 | b572a5d43fa4360c1a070b361593fea518e6e689ae5b2cca2dce0628ab2b93c1 |
Hashes for scandir_rs-2.8.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fcb876641e42603c80e2afa06efcb204da556dcb4d811906a1063bee0984722 |
|
MD5 | a4e812517d0aacdc92b70b8cf818ca4d |
|
BLAKE2b-256 | 45c8fc79d43be7392a1da79fbd3310a3c85fc23ae6ff2f11fd801db00af05ba8 |
Hashes for scandir_rs-2.8.0-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 633208ee1e7776ecc97ba778086339cd7b2e800442c8e9f636e9e307455a91e7 |
|
MD5 | bfb137d713cd6b741f630e47ec44aa2b |
|
BLAKE2b-256 | e97d0d45e0a56697cf4066b17781c3dc1c25a216a805f946f44c343b58fbc528 |
Hashes for scandir_rs-2.8.0-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08a8882e0ad10febf33d34fd4d233830a5ea37d4ee34a5edca15c9e460697be0 |
|
MD5 | 02fa60f70d5b8b9061dfaa3af209e761 |
|
BLAKE2b-256 | 136de854232e6e4a172a6f85b0072774365873ff3ca324fd438cb0eb2780c085 |
Hashes for scandir_rs-2.8.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 865d045eccc8b1aac80e3d019c413b7bff8ae4898f1a1b7714f562052d2f81a1 |
|
MD5 | ba0942d5c7344eb8875e78d905076dba |
|
BLAKE2b-256 | 86a49cbe9a299c5de390af0738e10e305b26200fe6592fff80bd3389510a6b96 |
Hashes for scandir_rs-2.8.0-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f70d0c40fbbb12b4f37e2873e2c85eb7eac19de03ffd55188d73d6e2cfef5a6d |
|
MD5 | 9399814a0ae9d8da270745a1fcebd37b |
|
BLAKE2b-256 | bdb562c745b106cb23c88ff667e0b374d96b65ccba7bc49ed2d19eed753d1937 |
Hashes for scandir_rs-2.8.0-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe250f3c4cbf1668aa542bc84e1e8cac18c0a29dc6c6c2c14b120064de91f2e1 |
|
MD5 | 188bb3d4e064172896be865c0921cdf0 |
|
BLAKE2b-256 | 1c9a7a0eae959e5acd0a67cae3d6e011352661cfcd8754d9a8abfd65af9339bd |
Hashes for scandir_rs-2.8.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b2458531feb82415929de15ae3f9b6f4964aca518f2f15f134840b84c13244d |
|
MD5 | 52c5d5b091a2b5c77ebfb67b34be844b |
|
BLAKE2b-256 | 2bacbbe557edfe17a18b4f3b54438511fddbc85b777e5f7a900f7f445eb707f3 |