A Rust library for parsing and generating A2L files.
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.7.0-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63a95c3024cbf122640898f0bd1865d5db1d1a1bdb4628918c009ae510fafb2e |
|
MD5 | 90435243c9888fda075b83fbfdf74877 |
|
BLAKE2b-256 | e11243d3b1586616ec5a95bd37958f9949f79bba6a2623ae8f0116f325e33022 |
Hashes for scandir_rs-2.7.0-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fef7e4760465c59429f97441928e058aa484f98af78e3ef78a09333cc5b14885 |
|
MD5 | 57b3911bb11323ab93156909c16748e5 |
|
BLAKE2b-256 | d1b10bbc4b3e4100ffa1ceaf5276ff235ab1ab67f0daf53aafbd035013313290 |
Hashes for scandir_rs-2.7.0-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a59705f8fff195ba06b962b4326dd26ddf048d9909641767885ccd5d4d7c436 |
|
MD5 | 5accf7d5e4a2ba3dec23fc3d6ef5537b |
|
BLAKE2b-256 | 43b8d567d7634a80b0b6a0235702353fef24d4befe4621ce72903c6005bc6381 |
Hashes for scandir_rs-2.7.0-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bae244a402a77435b96dae75b08679076d5bdd92c5f0ac2d139c03f206204808 |
|
MD5 | cb6982a9cf4cc00aafa58230b3368b9b |
|
BLAKE2b-256 | 39e958e79181ed2ec96c5a556bc904d7e8cc86e4b1ff74ac9564ae8cda0c2d01 |
Hashes for scandir_rs-2.7.0-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6525f4edf1d048c4b90a300d9c791a92b5471b6e3d4594e290d07a280c4cd609 |
|
MD5 | 5b589b7931927bbb07705158fc5453ec |
|
BLAKE2b-256 | e36e8f996529a3835e978cd9a0550210a46a45b77a56ead228fb3d36cb2fbb3f |
Hashes for scandir_rs-2.7.0-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4df037b1818bb38e85fadd8fb862dfd04d24a96ead07c85204e5108c8cefac82 |
|
MD5 | 1a4b6abcb8f16b7a6df0666f5d1d59a8 |
|
BLAKE2b-256 | 78c14e5caa701d730a999a96b53ab69e6269ed6846991a8e9d494fb8ced28eea |