Re: [Python-Dev] File system path PEP, part 2

2016-05-12 Thread Nick Coghlan
On 13 May 2016 at 06:53, Brett Cannon wrote: > Second draft that takes Guido's comments into consideration. The biggest > change is os.fspath() now returns whatever path.__fspath__() returns instead > of restricting it to only str. > > Minor changes: > - Renamed the C function

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-05-12 Thread Brett Cannon
Marked as accepted in https://hg.python.org/peps/rev/a52066565cc2 On Thu, 12 May 2016 at 16:59 Guido van Rossum wrote: > Is anyone going to mark the PEP as accepted? > > On Thu, May 12, 2016 at 8:11 AM, Guido van Rossum > wrote: > >> OK, then PEP 515

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-05-12 Thread Guido van Rossum
Is anyone going to mark the PEP as accepted? On Thu, May 12, 2016 at 8:11 AM, Guido van Rossum wrote: > OK, then PEP 515 is now officially accepted! Congratulations. Start the > implementation work! > > --Guido (mobile) > On May 11, 2016 10:33 PM, "Georg Brandl"

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Brett Cannon
On Thu, 12 May 2016 at 14:04 Sjoerd Job Postmus wrote: > > > > On 12 May 2016, at 21:30, Ethan Furman wrote: > > > > If you need bytes support for your paths, there's at least one [1] that > has that support. > > So if I would need bytes support, I

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Sjoerd Job Postmus
> On 12 May 2016, at 21:30, Ethan Furman wrote: > > If you need bytes support for your paths, there's at least one [1] that has > that support. So if I would need bytes support, I should submit a pull request to which replaces usage of the stdlib pathlib with another

[Python-Dev] File system path PEP, part 2

2016-05-12 Thread Brett Cannon
Second draft that takes Guido's comments into consideration. The biggest change is os.fspath() now returns whatever path.__fspath__() returns instead of restricting it to only str. Minor changes: - Renamed the C function to PyOS_FSPath() - Added an Implementation section with a TODO list - Bunch

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Ethan Furman
On 05/12/2016 10:22 AM, Sjoerd Job Postmus wrote: However, if it were to reject bytes, that would mean that when libraries start to use pathlib, it would suddenly become harder for people that actually need bytes-support to use pathlib. pathlib is not about bytes support. While bytes are

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Guido van Rossum
There's no need for typing.PathLike. -- --Guido van Rossum (python.org/~guido) ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe:

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Brett Cannon
On Thu, 12 May 2016 at 12:03 Guido van Rossum wrote: > On Thu, May 12, 2016 at 11:51 AM, Brett Cannon wrote: > >> >> Anyway, with your strong preference of how to tweak os.fspath() what >> specifically would you like to see discussed at this point? >> > >

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Guido van Rossum
On Thu, May 12, 2016 at 11:51 AM, Brett Cannon wrote: > > Anyway, with your strong preference of how to tweak os.fspath() what > specifically would you like to see discussed at this point? > Preferably nothing. :-) There's been too much discussion already. > Assuming the

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Brett Cannon
On Thu, 12 May 2016 at 11:36 Guido van Rossum wrote: > On Thu, May 12, 2016 at 10:18 AM, Brett Cannon wrote: > >> On Thu, 12 May 2016 at 09:25 Guido van Rossum wrote: >> > def fspath(p: Union[str, bytes, PathLike]) -> Union[str, bytes]: >>>

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Guido van Rossum
On Thu, May 12, 2016 at 10:18 AM, Brett Cannon wrote: > > On Thu, 12 May 2016 at 09:25 Guido van Rossum wrote: > >> def fspath(p: Union[str, bytes, PathLike]) -> Union[str, bytes]: >> if isinstance(p, (str, bytes)): >> return p >> try: >>

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Koos Zevenhoven
On Thu, May 12, 2016 at 8:22 PM, Sjoerd Job Postmus wrote: > I would like to make just 1 comment regarding the question of accepting > (or not) bytes as output of `os.fspath`. > > The whole point of adding `os.fspath` is to make it easier to use Path > objects. This is in

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Koos Zevenhoven
On Thu, May 12, 2016 at 7:24 PM, Guido van Rossum wrote: > I am glad this is finally happening. There's quite a bit of noise in the > thread which I have to ignore. The two issues that I want to respond to are > speed and whether os.fspath() can return bytes. > > - Speed: We

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Sjoerd Job Postmus
I would like to make just 1 comment regarding the question of accepting (or not) bytes as output of `os.fspath`. The whole point of adding `os.fspath` is to make it easier to use Path objects. This is in an effort to gain greater adoption of pathlib in libraries. Now, this is an excellent idea.

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Ethan Furman
On 05/12/2016 10:21 AM, Sven R. Kunze wrote: On 12.05.2016 18:56, Ethan Furman wrote: On 05/12/2016 09:26 AM, Sven R. Kunze wrote: str and bytes will receive the __fspath__ attribute when this PEP is accepted? No, they won't. The __fspath__ protocol will reduce the rich path object down

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Sven R. Kunze
On 12.05.2016 18:56, Ethan Furman wrote: On 05/12/2016 09:26 AM, Sven R. Kunze wrote: str and bytes will receive the __fspath__ attribute when this PEP is accepted? No, they won't. The __fspath__ protocol will reduce the rich path object down to a str/bytes object. Would this make the

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Brett Cannon
On Thu, 12 May 2016 at 09:25 Guido van Rossum wrote: > I am glad this is finally happening. There's quite a bit of noise in the > thread which I have to ignore. > Don't worry, I'm not ignoring it on your behalf. :) > The two issues that I want to respond to are speed and

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Ethan Furman
On 05/12/2016 09:26 AM, Sven R. Kunze wrote: On 12.05.2016 17:42, Ethan Furman wrote: On 05/12/2016 01:31 AM, Sven R. Kunze wrote: I think the "Rationale" section ignores the fact the Path also supports the .path attribute now. Which indeed defines a common interface between path objects.

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Sven R. Kunze
On 12.05.2016 17:42, Ethan Furman wrote: On 05/12/2016 01:31 AM, Sven R. Kunze wrote: I think the "Rationale" section ignores the fact the Path also supports the .path attribute now. Which indeed defines a common interface between path objects. The version of Python that has Path.path has

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Guido van Rossum
I am glad this is finally happening. There's quite a bit of noise in the thread which I have to ignore. The two issues that I want to respond to are speed and whether os.fspath() can return bytes. - Speed: We should trust our ability to optimize the implementations where necessary. First the API

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Sven R. Kunze
On 11.05.2016 23:57, Brett Cannon wrote: On Wed, 11 May 2016 at 14:29 Nikolaus Rath > wrote: On May 11 2016, Brett Cannon > wrote: > This PEP proposes a protocol for classes which represent a

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Ethan Furman
On 05/12/2016 01:31 AM, Sven R. Kunze wrote: I think the "Rationale" section ignores the fact the Path also supports the .path attribute now. Which indeed defines a common interface between path objects. The version of Python that has Path.path has not been released yet. And even so, .path

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals (revision 3)

2016-05-12 Thread Guido van Rossum
OK, then PEP 515 is now officially accepted! Congratulations. Start the implementation work! --Guido (mobile) On May 11, 2016 10:33 PM, "Georg Brandl" wrote: I'm happy with the latest version. Georg On 05/11/2016 06:46 PM, Guido van Rossum wrote: > If the authors are happy

Re: [Python-Dev] Slow downloads from python.org

2016-05-12 Thread Dima Tisnek
Gone now, must've been transient. I've no idea if it was python end, my end (tail?) or something slithery inbetween. On 11 May 2016 at 20:17, Brett Cannon wrote: > > > On Wed, 11 May 2016 at 10:56 Dima Tisnek wrote: >> >> Sorry, this is probably wrong place

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Koos Zevenhoven
On Thu, May 12, 2016 at 4:20 PM, Nick Coghlan wrote: > > It's not unusual for me to encounter "POSIX oughtta be enough for > anyone" folks that are not yet entirely convinced that > bytes-are-not-text, so I'm actually in favour of making the default > Python-level API str-only

Re: [Python-Dev] PyGC_Collect ignores state of `enabled`

2016-05-12 Thread Armin Rigo
Hi Lukasz, On 10 May 2016 at 04:13, Ɓukasz Langa wrote: > However, because of PyGC_Collect() called in Py_Finalize(), during > interpreter shutdown the collection is done anyway, Linux does CoW and the > memory usage spikes. Which is ironic on process shutdown. Try to call

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Nick Coghlan
On 12 May 2016 at 22:40, Koos Zevenhoven wrote: > On Thu, May 12, 2016 at 3:04 PM, Nick Coghlan wrote: >> >> I'd still like to see this exposed to Python code as os._raw_fspath() >> (with the leading underscore just meaning "this probably isn't the API >>

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Koos Zevenhoven
On Thu, May 12, 2016 at 3:04 PM, Nick Coghlan wrote: > > I'd still like to see this exposed to Python code as os._raw_fspath() > (with the leading underscore just meaning "this probably isn't the API > you want" rather than indicating a private or unstable API), and then >

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Nick Coghlan
On 12 May 2016 at 02:43, Brett Cannon wrote: > **deep, calming breath** > > Here is the PEP for __fspath__(). The draft lives at > https://github.com/brettcannon/path-pep so feel free to send me PRs for > spelling mistakes, grammatical errors, etc. Thanks for putting this

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Koos Zevenhoven
On Thu, May 12, 2016 at 11:31 AM, Sven R. Kunze wrote: > On 11.05.2016 18:43, Brett Cannon wrote: >> >> Rationale >> = >> >> Historically in Python, file system paths have been represented as >> strings or bytes. This choice of representation has stemmed from C's >> own

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Koos Zevenhoven
On Thu, May 12, 2016 at 11:14 AM, Serhiy Storchaka wrote: > > This is cheap in C, but os.path functions are implemented in Python. They > have to make at least one function call (os.fspath(), hasattr() or > isinstance()), not counting a bytecode for retrieving arguments,

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Sven R. Kunze
Thanks Brett for your hard work. My comments below: On 11.05.2016 18:43, Brett Cannon wrote: Rationale = Historically in Python, file system paths have been represented as strings or bytes. This choice of representation has stemmed from C's own decision to represent file system paths

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Serhiy Storchaka
On 12.05.16 10:54, Ethan Furman wrote: Currently, any of these functions that already take a string have to do a couple pointer comparisons to make sure they have a string; any of these functions that take both a string and a bytes have to do a couple pointer comparisons to make sure they have a

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Sven R. Kunze
On 12.05.2016 00:13, Brett Cannon wrote: I see this whole discussion breaking down into a few groups which changes what gets done upfront and what might be done farther down the line: 1. Maximum acceptance: do whatever we can to make all representation of paths just work, which means

Re: [Python-Dev] file system path protocol PEP

2016-05-12 Thread Ethan Furman
On 05/11/2016 09:55 PM, Serhiy Storchaka wrote: [...] But for example os.walk() was significantly boosted with using os.scandir(), it would be sad to make it slower again. scandir's speed improvement is due to not not throwing away data the OS was already giving us. os.path is used in