mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-46848: Use stringlib/fastsearch in mmap (GH-31625)
Speed up mmap.find(). Add _PyBytes_Find() and _PyBytes_ReverseFind().
This commit is contained in:
parent
9833bb91e4
commit
6ddb09f35b
4 changed files with 53 additions and 19 deletions
|
@ -1247,6 +1247,24 @@ PyBytes_AsStringAndSize(PyObject *obj,
|
|||
|
||||
#undef STRINGLIB_GET_EMPTY
|
||||
|
||||
Py_ssize_t
|
||||
_PyBytes_Find(const char *haystack, Py_ssize_t len_haystack,
|
||||
const char *needle, Py_ssize_t len_needle,
|
||||
Py_ssize_t offset)
|
||||
{
|
||||
return stringlib_find(haystack, len_haystack,
|
||||
needle, len_needle, offset);
|
||||
}
|
||||
|
||||
Py_ssize_t
|
||||
_PyBytes_ReverseFind(const char *haystack, Py_ssize_t len_haystack,
|
||||
const char *needle, Py_ssize_t len_needle,
|
||||
Py_ssize_t offset)
|
||||
{
|
||||
return stringlib_rfind(haystack, len_haystack,
|
||||
needle, len_needle, offset);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
PyBytes_Repr(PyObject *obj, int smartquotes)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue