[pypy-commit] pypy default: Issue #1779: PyList_GetItem() took a time proportional to the length of

arigo noreply at buildbot.pypy.org
Wed Jul 2 16:26:16 CEST 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r72314:07de89e151e9
Date: 2014-07-02 16:24 +0200
http://bitbucket.org/pypy/pypy/changeset/07de89e151e9/

Log:	Issue #1779: PyList_GetItem() took a time proportional to the length
	of the list in case the list's strategy is not the default one.

diff --git a/pypy/module/cpyext/listobject.py b/pypy/module/cpyext/listobject.py
--- a/pypy/module/cpyext/listobject.py
+++ b/pypy/module/cpyext/listobject.py
@@ -46,11 +46,11 @@
     IndexError exception."""
     if not isinstance(w_list, W_ListObject):
         PyErr_BadInternalCall(space)
-    wrappeditems = w_list.getitems()
-    if index < 0 or index >= len(wrappeditems):
+    if index < 0 or index >= w_list.length():
         raise OperationError(space.w_IndexError, space.wrap(
             "list index out of range"))
-    return borrow_from(w_list, wrappeditems[index])
+    w_item = w_list.getitem(index)
+    return borrow_from(w_list, w_item)
 
 
 @cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)


More information about the pypy-commit mailing list