Kaydet (Commit) cb3e580e authored tarafından Raymond Hettinger's avatar Raymond Hettinger

Optimize list.pop() for the common special case of popping off the end.

More than doubles its speed.
üst 4bb9540d
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment