diff options
Diffstat (limited to 'Objects/stringobject.c')
-rw-r--r-- | Objects/stringobject.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c index fff4b45..8d0f4b8 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -1146,6 +1146,17 @@ string_subscript(PyStringObject* self, PyObject* item) if (slicelength <= 0) { return PyString_FromStringAndSize("", 0); } + else if (start == 0 && step == 1 && + slicelength == PyString_GET_SIZE(self) && + PyString_CheckExact(self)) { + Py_INCREF(self); + return (PyObject *)self; + } + else if (step == 1) { + return PyString_FromStringAndSize( + PyString_AS_STRING(self) + start, + slicelength); + } else { source_buf = PyString_AsString((PyObject*)self); result_buf = (char *)PyMem_Malloc(slicelength); |