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 string or a bytes;  the
only difference if this PEP is accepted is the fall-back path when those
first checks fail.

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, resolving attributes, comparing, jumps. Currently os.path functions use tricks to avoid overheads

Yet one problem is that currently many os,path functions work with duck-typed strings (e.g. UserString). Using os.fspath() likely limit supported types to str, bytes and types that support the path protocol.


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to