[Python-ideas] tweaking the file system path protocol
Serhiy Storchaka
storchaka at gmail.com
Tue May 23 17:18:16 EDT 2017
23.05.17 20:04, Brett Cannon пише:
> On Tue, 23 May 2017 at 03:13 Wolfgang Maier
> <wolfgang.maier at biologie.uni-freiburg.de
> <mailto:wolfgang.maier at biologie.uni-freiburg.de>> wrote:
> My proposal is to change this to:
> 1) check whether the type of the argument is str or bytes *exactly*; if
> so, return the argument unchanged
> 2) check wether __fspath__ can be called on the type and returns an
> instance of str, bytes, or any subclass (just like in the current
> version)
> 3) check whether the type is a subclass of str or bytes and, if so,
> return it unchanged
>
> What exactly is the performance issue you are having that is leading to
> this proposal?
It seems to me that the purpose of this proposition is not performance,
but the possibility to use __fspath__ in str or bytes subclasses.
Currently defining __fspath__ in str or bytes subclasses doesn't have
any effect.
I don't know a reasonable use case for this feature. The __fspath__
method of str or bytes subclasses returning something not equivalent to
self looks confusing to me.
More information about the Python-ideas
mailing list