-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Move pathlib implementation out of __init__.py
#118582
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
Conversation
Using the `asyncio` package as a model.
@eryksun you mentioned renaming
... because that would speed up the import of |
Great if that really helps with performance. My issue was more trivial. I like to have easily recognizable names on tabs in my IDE. "_pathlib_abc.py" is a name that I can recognize in an instant without having to hover or use the document viewer. |
Hm. If I thumb through the standard library, there are quite a few submodules with generic basenames: |
No, not on tabs, and I wouldn't want qualified names on tabs. That's what the tree view of the documents viewer is for if I really need it. I know the standard library doesn't generally use easily recognizable module names in packages. That's why I qualified the asyncio example for what I personally prefer, and only for generic private names. Some names are easy for me to remember in context, such as "pool.py" in multiprocessing. It's just generic private names such as "_constants.py" that I wish had better names, since they aren't meant to be used in the public API anyway. But really almost anything is better than staring at a bunch of tabs labeled "__init__.py". |
Well, the |
Use the `__init__.py` file only for imports that define the API, following the example of asyncio.
Great to see the work going into pathlib for the next version of Python :). Apologies if this isn't the right place to bring this up and/or if this is already known/expected, but I wanted to highlight that moving the implementations of pathlib prevents pickles coming from Python 3.13 (specifically I'm testing at 3.13.0b2) being loaded on earlier versions of Python (the other way around works fine). I realise that this probably isn't something where backwards compatibility is expected and that moving pickles between versions maybe not desirable, though it is used in a few places -- notably Jedi does so. For Jedi I've worked around this pretty easily by adding a custom I'm not sure what's expected around moves like this, so if the default is "nothing" that's probably fine! It might be nice to call out the refactoring in the release notes though? |
Use the
__init__.py
file only for imports that define the API, following the example ofasyncio
.See https://discuss.python.org/t/make-pathlib-extensible/3428/172