-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Returning Path
instead of str
instances
#3
Comments
|
You're right. No need to have a half-migration path. |
(The pedant in me will also mention that there are versions of 2.7 that are not EOL'ed, i.e. PyPy, but certainly if it causes even trivial extra effort, like requiring us to depend on And as for the specific idea, yeah, returning |
I'd never heard of
|
The order of the two items in my original message is by design: dropping those versions is a blocker to adopting I believe that pre-3.6, The key difference is, applications would fail on python3.5 due to an API very inconsistent with |
If I understood correctly, then we should make a release with the support of all Python (which virtualenv supports) to switch virtualenv to us, and then drop all EOL Pythons (include PyPy) and add support for pathlib? Or we will still have compatibility with EOL Pythons? |
That makes sense to me. I'm curious on whether |
As long as there's one python 2 compatible release virtualenv will be fine. virtualenv plans to support Python versions two years past their grace period - https://gaborbernat.github.io/euro_python_2019/#/55; so will not drop Python 2 support until January 1st. But yeah PyPy2 support on virtualenv side might hold back virtualenv on Python 2 land for longer... |
providing a path type aware wrapper might be nice so one could get a |
That sounds a lot like https://adamj.eu/tech/2021/07/10/python-type-hints-how-to-avoid-the-boolean-trap/, I think it's better to have new method names for the path variant 😊 |
@gaborbernat So, when it comes to naming the new methods, what do you think about adding a
Also, do I see it correctly, that the implementation would just need to wrap their |
And yes. |
@gaborbernat Those look great! Was gonna mentioned the same thing :) I intended to eventually handle Paths completely internally (e.g.: |
I would sit down later today and implement these. @WhyNotHugo I do not think there is much benefit of changing the internal representation. IIRC using pathlib can also be slower in some cases? Not sure about this, though. If I am wrong, and there are good arguments for changing the internal representation, I would be happy to give that a go, too. |
It probably doesn't make sense to change it internally if the `str` methods will remain. Though I'm honestly very curious how both implementations would compare in terms of performance.
|
No, the str variant is the faster. That remains the internal default form. |
I based my implementation on #26. I will wait with creating a PR until it is merged. If you have any feedback already, please let me know.
I am also waiting for MichaelAquilina/flake8-spellcheck#50 to be merged such that the implementation passes the flake8 spellcheck. Edit: Added docs |
Well that saves me the trouble of benchmarking it myself. Thanks for testing that. |
Creating a class (which pathlib is) will always be slower than just a raw string. See psf/black#1950 for a war story on this. |
Sure, creating the class itself is slower, but operations on it can be faster due to... implementation. Anyway, a benchmark is enough, if numbers show it to be slower, there's no point in discussing it further. |
I'd be surprised if the core developers have one implementation for os.path and another for pathlib properties. Considering most of os.path is already written in C I don't think I see much opportunity for pathlib to be faster. IMHO pathlib is just a syntactic sugar for the end user (in some cases it's easier) but offers no performance benefits. |
Done by #27. |
As mentioned in ActiveState/appdirs#79, I've been working on another fork of
appdirs
, but would rather hold off on publishing that and focus all efforts in one place.I mostly have two changes in places:
Path
instance, to make usage on consumer libraries easier. This kinda means it's not a 100% drop-in replacement, but rather an upgrade (e.g.: like a major).Maybe it would make sense to have a
platformdirs==1.0.0
release, which is functionally identical toappdirs
(to allow seamless switching), and then start merging in any non-backwards-compatible changes. Thoughts?The text was updated successfully, but these errors were encountered: