Mark Dickinson <[email protected]> added the comment:
Given that we typically need at least 4 bytes just for the PyObject * pointer
for each item in a list, I guess real lists are safe.
But how about list-like objects, implementing __len__ and __getitem__? The
following appears to run forever on my machine:
class SquaresList(object):
def __init__(self, length):
self._length = length
def __len__(self):
return self._length
def __getitem__(self, index):
if not 0 <= index <= self._length:
raise IndexError
return index**2
import bisect, sys
squareslist = SquaresList(sys.maxsize)
print bisect.bisect(squareslist, (sys.maxsize - 3)**2)
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue13496>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com