1.1 --- a/lib/__builtins__/tuple.py Sun Oct 30 22:33:22 2016 +0100
1.2 +++ b/lib/__builtins__/tuple.py Mon Oct 31 18:26:36 2016 +0100
1.3 @@ -20,13 +20,18 @@
1.4 """
1.5
1.6 from __builtins__.iterator import listiterator
1.7 -from __builtins__.sequence import _getitem, _getslice, _tuple
1.8 +from __builtins__.sequence import _getitem, _getslice
1.9 +import native
1.10
1.11 class tuple(object):
1.12
1.13 "Implementation of tuple."
1.14
1.15 - def __init__(self, args): pass
1.16 + def __init__(self, args=None):
1.17 +
1.18 + "Initialise the tuple."
1.19 +
1.20 + self.__data__ = native._tuple_init(args) # allocate and copy elements
1.21
1.22 def __getitem__(self, index):
1.23
1.24 @@ -38,10 +43,16 @@
1.25
1.26 "Return a slice starting from 'start', with the optional 'end'."
1.27
1.28 - return _tuple(_getslice(self, start, end))
1.29 + return native._list_to_tuple(_getslice(self, start, end))
1.30 +
1.31 + def __len__(self):
1.32
1.33 - def __len__(self): pass
1.34 + "Return the length of the tuple."
1.35 +
1.36 + return native._tuple_len(self)
1.37 +
1.38 def __add__(self, other): pass
1.39 +
1.40 def __str__(self): pass
1.41
1.42 def __bool__(self):
1.43 @@ -58,6 +69,7 @@
1.44
1.45 # Special implementation methods.
1.46
1.47 - def __get_single_item__(self, index): pass
1.48 + def __get_single_item__(self, index):
1.49 + return native._tuple_element(self, index)
1.50
1.51 # vim: tabstop=4 expandtab shiftwidth=4