Author: Armin Rigo <[email protected]>
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)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to