[issue30247] Make importlib.machinery class handle os.PathLike path

Brett Cannon report at bugs.python.org
Wed May 3 12:50:19 EDT 2017


Brett Cannon added the comment:

The classes mentioned actually require that the path exist on the file system so there's no extra restrictions. As for cost, it's pretty cheap as a call to _os.fspath() is written in C and does an immediate type-check for str or bytes for the common-case (https://github.com/python/cpython/blob/master/Modules/posixmodule.c#L12099). These classes are also instantiated once typically and then cached so the cost is only paid once per object.

As for use-cases, I've seen people directly instantiate these classes in user code and so supporting paths in a universal way like the rest of the stdlib would be good for consistency.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30247>
_______________________________________


More information about the Python-bugs-list mailing list