[Python-ideas] tweaking the file system path protocol

2017-05-23 Thread Wolfgang Maier
What do you think of this idea for a slight modification to os.fspath: the current version checks whether its arg is an instance of str, bytes or any subclass and, if so, returns the arg unchanged. In all other cases it tries to call the type's __fspath__ method to see if it can get str, bytes,

Re: [Python-ideas] tweaking the file system path protocol

2017-05-23 Thread Steven D'Aprano
On Tue, May 23, 2017 at 12:12:11PM +0200, Wolfgang Maier wrote: > Here's how the proposal could be implemented in the pure Python version > (os._fspath): > > def _fspath(path): > path_type = type(path) > if path_type is str or path_type is bytes: > return path How about simplify

Re: [Python-ideas] JavaScript-Style Object Creation in Python (using a constructor function instead of a class to create objects)

2017-05-23 Thread Sven R. Kunze
On 20.05.2017 18:06, Nick Coghlan wrote: That's fine for someone that's already comfortable writing those behaviours by hand and just wants to automate the boilerplate away (which is exactly the problem that attrs was written to solve), but it's significantly more problematic once we assume peopl

Re: [Python-ideas] tweaking the file system path protocol

2017-05-23 Thread Koos Zevenhoven
On Tue, May 23, 2017 at 1:12 PM, Wolfgang Maier wrote: > What do you think of this idea for a slight modification to os.fspath: > the current version checks whether its arg is an instance of str, bytes or > any subclass and, if so, returns the arg unchanged. In all other cases it > tries to call t

Re: [Python-ideas] tweaking the file system path protocol

2017-05-23 Thread Koos Zevenhoven
On Tue, May 23, 2017 at 1:49 PM, Steven D'Aprano wrote: > > How about simplifying the implementation of fspath by giving str and > bytes a __fspath__ method that returns str(self) or bytes(self)? > The compatiblity issue I mention in the other email I just sent as a response to the OP will appear

Re: [Python-ideas] tweaking the file system path protocol

2017-05-23 Thread Wolfgang Maier
On 05/23/2017 06:41 PM, Wolfgang Maier wrote: On 05/23/2017 06:17 PM, Koos Zevenhoven wrote: On Tue, May 23, 2017 at 1:12 PM, Wolfgang Maier wrote: What do you think of this idea for a slight modification to os.fspath: the current version checks whether its arg is an instance of str, bytes or

Re: [Python-ideas] tweaking the file system path protocol

2017-05-23 Thread Wolfgang Maier
On 05/23/2017 06:17 PM, Koos Zevenhoven wrote: On Tue, May 23, 2017 at 1:12 PM, Wolfgang Maier wrote: What do you think of this idea for a slight modification to os.fspath: the current version checks whether its arg is an instance of str, bytes or any subclass and, if so, returns the arg unchan

Re: [Python-ideas] tweaking the file system path protocol

2017-05-23 Thread Brett Cannon
On Tue, 23 May 2017 at 03:13 Wolfgang Maier < [email protected]> wrote: > What do you think of this idea for a slight modification to os.fspath: > the current version checks whether its arg is an instance of str, bytes > or any subclass and, if so, returns the arg unchanged.

Re: [Python-ideas] tweaking the file system path protocol

2017-05-23 Thread Guido van Rossum
I see no future for this proposal. Sorry Wolfgang! For future reference, the proposal was especially weak because it gave no concrete examples of code that was inconvenienced in any way by the current behavior. (And the performance hack of checking for exact str/bytes can be made without changing t

Re: [Python-ideas] tweaking the file system path protocol

2017-05-23 Thread Koos Zevenhoven
On Tue, May 23, 2017 at 7:53 PM, Wolfgang Maier wrote: > > Ah, sorry, I misunderstood what you were trying to say, but now I'm getting > it! subclasses of str and bytes were of course usable as path arguments > before simply because they were subclasses of them. Now they would be picked > up based

Re: [Python-ideas] tweaking the file system path protocol

2017-05-23 Thread Serhiy Storchaka
23.05.17 20:04, Brett Cannon пише: On Tue, 23 May 2017 at 03:13 Wolfgang Maier > 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) c

Re: [Python-ideas] tweaking the file system path protocol

2017-05-23 Thread Koos Zevenhoven
On Wed, May 24, 2017 at 12:18 AM, Serhiy Storchaka wrote: > 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 kn

Re: [Python-ideas] tweaking the file system path protocol

2017-05-23 Thread tritium-list
> -Original Message- > From: Python-ideas [mailto:python-ideas-bounces+tritium- > [email protected]] On Behalf Of Koos Zevenhoven > Sent: Tuesday, May 23, 2017 5:31 PM > To: Serhiy Storchaka > Cc: python-ideas > Subject: Re: [Python-ideas] tweaking the file system path protocol

Re: [Python-ideas] tweaking the file system path protocol

2017-05-23 Thread Steven D'Aprano
On Wed, May 24, 2017 at 12:18:16AM +0300, Serhiy Storchaka wrote: > 23.05.17 20:04, Brett Cannon пише: > >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 t