Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
gh-102511: Add C implementation of os.path.splitroot()#118089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
c397a234bd97340177f70e9cdec5bb816e9d00131aa4e5d157e1433c54911522244d3fca0761ae1f32e934d4d9030d613bf78bad05635da56f62c1f2e1b11a92d1c955d35720bb9b34dbb64b1875e3a70ef0ce7fdf9f9749cd7951f87f82b62a42fb6a74f15File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Speed up :func:`os.path.splitroot` with a native implementation. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -5467,6 +5467,49 @@ os__path_islink_impl(PyObject *module, PyObject *path) | ||
| #endif /* MS_WINDOWS */ | ||
| /*[clinic input] | ||
| os._path_splitroot_ex | ||
| path: unicode | ||
| [clinic start generated code]*/ | ||
| static PyObject * | ||
| os__path_splitroot_ex_impl(PyObject *module, PyObject *path) | ||
nineteendo marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| /*[clinic end generated code: output=de97403d3dfebc40 input=f1470e12d899f9ac]*/ | ||
| { | ||
| Py_ssize_t len, drvsize, rootsize; | ||
| PyObject *drv = NULL, *root = NULL, *tail = NULL, *result = NULL; | ||
| wchar_t *buffer = PyUnicode_AsWideCharString(path, &len); | ||
| if (!buffer) { | ||
| goto exit; | ||
| } | ||
| _Py_skiproot(buffer, len, &drvsize, &rootsize); | ||
| drv = PyUnicode_FromWideChar(buffer, drvsize); | ||
| if (drv == NULL) { | ||
| goto exit; | ||
| } | ||
| root = PyUnicode_FromWideChar(&buffer[drvsize], rootsize); | ||
| if (root == NULL) { | ||
| goto exit; | ||
| } | ||
| tail = PyUnicode_FromWideChar(&buffer[drvsize + rootsize], | ||
| len - drvsize - rootsize); | ||
| if (tail == NULL) { | ||
| goto exit; | ||
| } | ||
| result = Py_BuildValue("(OOO)", drv, root, tail); | ||
| exit: | ||
| PyMem_Free(buffer); | ||
| Py_XDECREF(drv); | ||
| Py_XDECREF(root); | ||
| Py_XDECREF(tail); | ||
| return result; | ||
| } | ||
| /*[clinic input] | ||
| os._path_normpath | ||
| @@ -16799,6 +16842,7 @@ static PyMethodDef posix_methods[] = { | ||
| OS__FINDFIRSTFILE_METHODDEF | ||
| OS__GETVOLUMEPATHNAME_METHODDEF | ||
| OS__PATH_SPLITROOT_METHODDEF | ||
| OS__PATH_SPLITROOT_EX_METHODDEF | ||
| OS__PATH_NORMPATH_METHODDEF | ||
| OS_GETLOADAVG_METHODDEF | ||
| OS_URANDOM_METHODDEF | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.