[Python-Dev] pathlib - current status of discussions (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Mon Apr 11 23:58:29 EDT 2016
- Previous message (by thread): [Python-Dev] pathlib - current status of discussions
- Next message (by thread): [Python-Dev] pathlib - current status of discussions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 12 April 2016 at 13:45, Nick Coghlan <ncoghlan at gmail.com> wrote:
Consider os.path.join: with a permissive os.fspath, the necessary update should just be to introduce "map(os.fspath, args)" (or its C equivalent), and then continue with the existing bytes vs str handling logic.
That does remind me: once a patch is available, we should check the benchmark numbers with the patch applied. I'd expect the new protocol overhead to be swamped by the actual IO costs, but this kind of low level change can have surprising consequences.
Regarding the type checks, PyObject_AsFilesystemPath (or whatever we call it) will be implemented in C, with os.fspath just calling that, so doing "PyUnicode_Check(path) || PyBytes_Check(path)" on the result will be both cheap and convenient for API consumers (since it means they know they only have to cope with bytes or str instances internally, and will get a clear error message if handed something else).
Cheers, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message (by thread): [Python-Dev] pathlib - current status of discussions
- Next message (by thread): [Python-Dev] pathlib - current status of discussions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]