1.1 --- a/lib/__builtins__/list.py Sun Feb 05 18:12:40 2017 +0100
1.2 +++ b/lib/__builtins__/list.py Sun Feb 05 18:17:14 2017 +0100
1.3 @@ -20,7 +20,7 @@
1.4 """
1.5
1.6 from __builtins__.iteration.iterator import itemiterator
1.7 -from __builtins__.sequence import sequence
1.8 +from __builtins__.sequence import sequence, _get_absolute_index
1.9 from native import list_append, list_concat, list_element, list_init, \
1.10 list_len, list_nonempty, list_setelement, list_setsize
1.11
1.12 @@ -40,7 +40,22 @@
1.13 if args is not None:
1.14 self.extend(args)
1.15
1.16 - def __delitem__(self, index): pass
1.17 + def __delitem__(self, index):
1.18 +
1.19 + "Delete the item at 'index'."
1.20 +
1.21 + length = self.__len__()
1.22 + index = _get_absolute_index(index, length)
1.23 + last = length - 1
1.24 +
1.25 + while index < last:
1.26 + self[index] = self[index + 1]
1.27 + index += 1
1.28 +
1.29 + # NOTE: Should truncate the allocated list after several pops.
1.30 +
1.31 + list_setsize(self.__data__, last)
1.32 +
1.33 def __setslice__(self, start, end, slice): pass
1.34 def __delslice__(self, start, end): pass
1.35