https://github.com/juftin/pathlibrs
A ⚡️fast⚡️ implementation of the pathlib.Path class. Written in Rust, built for Python.
https://github.com/juftin/pathlibrs
maturin pathlib pyo3 python rust
Last synced: about 1 year ago
JSON representation
A ⚡️fast⚡️ implementation of the pathlib.Path class. Written in Rust, built for Python.
- Host: GitHub
- URL: https://github.com/juftin/pathlibrs
- Owner: juftin
- Created: 2023-09-21T03:37:55.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-21T05:31:51.000Z (over 2 years ago)
- Last Synced: 2025-01-23T14:17:03.610Z (about 1 year ago)
- Topics: maturin, pathlib, pyo3, python, rust
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pathlib.rs
A ⚡️fast⚡️ implementation of the [pathlib.Path](https://docs.python.org/3/library/pathlib.html) class.
Written in Rust, built for Python.
## Usage
```python
from pathlibrs import Path
p = Path("foo/bar")
p.mkdir(parents=True)
baz_file = p / "baz.txt"
baz_file.write_text("Hello, world!")
```
## Performance
`pathlibrs` is much faster than the standard library's `pathlib` module
for certain operations. For example, traversing a directory tree can be
~4x faster:
```python
from pathlib import Path
from pathlibrs import Path as PathRS
p = Path("~/Downloads")
r = PathRS("~/Downloads")
%timeit
list(p.glob("**/*"))
# 1.03 s ± 6.04 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
%timeit
list(r.glob("**/*"))
# 253 ms ± 1.04 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
```