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

discussion: Using Path instead of PurePath #514

Open
mmngreco opened this issue Apr 11, 2023 · 1 comment
Open

discussion: Using Path instead of PurePath #514

mmngreco opened this issue Apr 11, 2023 · 1 comment
Labels
documentation Issue on documentation help wanted Extra attention is needed

Comments

@mmngreco
Copy link
Contributor

Just to don't messing up the PR ( #513) with another issue, I hope you guys find this issue ok.

@mmngreco: In addition, looking at the code, I was wondering why not use Path instead of
PurePath? With Path, you can use .resolve(), .expanduser(),
.absolute(), and many other methods that may replace (I think) functions
entirely (like canonical_path). But this probably should be placed in another
issue.

@miurahr In my understanding, when using Path , it will access actuall filesystem, and can be failed by file system error.
A path in archive should not be access to actualll path except for extracting or archiveing. It is why I use PurePath instead of Path for internal path handling that come from archive meta data.

In case it helps here is my 5cents: both Path and PurePath can be used for path manipulation, but the main difference is that Path also provides methods for filesystem operations (I/O operations) by retrieving the concrete path based on your OS. However, these filesystem operations are only invoked when you explicitly call them.

So, it doesn't matter if you are referencing an existent or non-existent file or directory; Path won't fail (for example you can do some wild things like instantiate a WindowsPath in Linux and use it to do some path manipulations but can't be use it to perform I/O operations).

In the case of canonical_path, as far as I understood, it assumes a concrete path (PosixPath), so using Path methods might be more efficient and avoid reinventing the wheel. Let me know if I'm mistaken in anything above.

@miurahr miurahr added help wanted Extra attention is needed documentation Issue on documentation labels Nov 5, 2023
@miurahr
Copy link
Owner

miurahr commented Apr 2, 2024

We may have a chance to use Path in topic branch and test it on several platforms in unit and integrate tests.
When it gives any wrong things, we can change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Issue on documentation help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants