[Python-Dev] file system path protocol PEP (original) (raw)

Koos Zevenhoven k7hoven at gmail.com
Wed May 11 17:22:22 EDT 2016


On Thu, May 12, 2016 at 12:15 AM, Ethan Furman <ethan at stoneleaf.us> wrote:

On 05/11/2016 01:51 PM, Ethan Furman wrote:

On 05/11/2016 01:44 PM, Serhiy Storchaka wrote:

os.path '''''''

The various path-manipulation functions of os.path [#os-path] will be updated to accept path objects. For polymorphic functions that accept both bytes and strings, they will be updated to simply use code very much similar to path._fspath_() if hasattr(path, '_fspath_') else path. This will allow for their pre-existing type-checking code to continue to function.

I afraid that this will hit a performance. Some os.path functions are used in tight loops, they are hard optimized, and adding support of path protocol can have visible negative effect. Do you have an example of os.path functions being used in a tight loop?

I'd be interested in this too.

Also, the C code for fspath can check types first and take the fast path if bytes/str are passed in, only falling back to the fspath protocol if something else was passed in -- which should make any performance hits negligible.

My suggestion for the python version already does this too (again, see my PR). This is a win-win, as it also improves error messages (as suggested by Nick in the earlier discussions).

-- Koos

-- Ethan


Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/k7hoven%40gmail.com



More information about the Python-Dev mailing list