Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPath: Implement more helper methods #10

Merged
merged 10 commits into from
Oct 21, 2024

Conversation

LightArrowsEXE
Copy link
Contributor

Implement some more methods that I would have uses for, and others may too.

@LightArrowsEXE
Copy link
Contributor Author

SPath.fglob speeds

$ python benchmark.py 
Total time for 10000 iterations: 0.4242 seconds
Average time per fglob call: 0.000042 seconds
Total time for 10000 simple glob iterations: 0.5244 seconds
Average time per simple glob call: 0.000052 seconds

oh ye, we zoomin' now

```bash
$ python benchmark.py
Total time for 10000 iterations: 0.4242 seconds
Average time per fglob call: 0.000042 seconds
Total time for 10000 simple glob iterations: 0.5244 seconds
Average time per simple glob call: 0.000052 seconds
```
def lglob(self, pattern: str = '*') -> list[SPath]:
"""Glob the path and return the list of paths."""

return [SPath(p) for p in self.glob(pattern)]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list and map

stgpytools/types/file.py Outdated Show resolved Hide resolved
stgpytools/types/file.py Outdated Show resolved Hide resolved

raise ValueError("Path is neither a file nor a directory")

def backup(self, dst: SPath | None = None) -> SPath:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the use for this? and why not copy_dir?

@Setsugennoao Setsugennoao merged commit eba8a9a into Setsugennoao:master Oct 21, 2024
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants