[Python-Dev] pathlib (was: Defining a path protocol)
Nick Coghlan
ncoghlan at gmail.com
Sat Apr 9 02:48:45 EDT 2016
On 8 April 2016 at 00:25, Jim J. Jewett <jimjjewett at gmail.com> wrote:
> (1) I think the "built-in" should instead be a module-level function
> in the pathlib. If you aren't already expecting pathlib paths, then
> you're just expecting strings to work anyhow, and a builtin isn't
> likely to be helpful.
Concrete data in relation to "Why not put the helper function in pathlib?":
>>> import sys
>>> orig_modules = set(sys.modules)
>>> "os" in orig_modules
True
>>> import pathlib
>>> extra_dependencies = set(sys.modules) - orig_modules
>>> print(sorted(extra_dependencies))
['_collections', '_functools', '_heapq', '_operator', '_sre',
'collections', 'contextlib', 'copyreg', 'fnmatch', 'functools',
'heapq', 'itertools', 'keyword', 'ntpath', 'operator', 'pathlib',
're', 'reprlib', 'sre_compile', 'sre_constants', 'sre_parse',
'urllib', 'urllib.parse', 'weakref']
We want to be able to readily use the protocol helper in builtin
modules like os and low level Python modules like os.path, which means
we want it to be much lower down in the import hierarchy than pathlib.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-Dev
mailing list