mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
Optimize list.pop() for the common special case of popping off the end.
More than doubles its speed.
This commit is contained in:
@@ -739,6 +739,11 @@ listpop(PyListObject *self, PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
v = self->ob_item[i];
|
||||
if (i == self->ob_size - 1) {
|
||||
if (list_resize(self, self->ob_size - 1) == -1)
|
||||
return NULL;
|
||||
return v;
|
||||
}
|
||||
Py_INCREF(v);
|
||||
if (list_ass_slice(self, i, i+1, (PyObject *)NULL) != 0) {
|
||||
Py_DECREF(v);
|
||||
|
||||
Reference in New Issue
Block a user