commit | cb3e580ebce784c2e5eb86cb30c842f66e29cb04 | [log] [tgz] |
---|---|---|
author | Raymond Hettinger <python@rcn.com> | Fri Feb 13 18:36:31 2004 +0000 |
committer | Raymond Hettinger <python@rcn.com> | Fri Feb 13 18:36:31 2004 +0000 |
tree | 4ec6bf0316cd4a3f9f94deb9dd75b8be44ddc995 | |
parent | 4bb9540dd6eddaf60b908796c2412696a8870bd1 [diff] |
Optimize list.pop() for the common special case of popping off the end. More than doubles its speed.
diff --git a/Objects/listobject.c b/Objects/listobject.c index 5bc4577..6651966 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c
@@ -739,6 +739,11 @@ 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);