[Python-ideas] New PEP proposal -- Pathlib Module Should Contain All File Operations
ncoghlan at gmail.com
Sun Mar 18 04:05:58 EDT 2018
On 16 March 2018 at 03:15, Chris Angelico <rosuav at gmail.com> wrote:
> On Fri, Mar 16, 2018 at 12:38 AM, George Fischhof <george at fischhof.hu>
> > " if new file functions are added, they will go only in pathlib,
> > which makes pathlib effectively mandatory;"
> > Yes but I think this part of the evolution: slowly everyone will shift to
> > pathlib,
> > and being mandatory is true for the current status as well: if you need a
> > function, you need the module.
> > Right now if you wan to execute some file operations, you need os plus
> > shutil, because the half of the
> > functions are in one of them, the other half is in the other module
> The os module is cheap; pathlib has a definite cost. If every file
> operation goes through pathlib
Keep in mind that the `os` layer will never go away: `pathlib` still needs
a lower level API to call to *do the work* of actually interacting with the
underlying operating system APIs (e.g. this is why we added os.scandir).
A similar situation applies when it comes to glob, fnmatch, etc.
Even `shutil` will likely retain its place as a lower level procedural API
behind pathlib's object-oriented facade, since raw strings are still
frequently going to be easier to work with when mixing and matching Python
code and native operating system shell code.
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas