Implement HySequence with tuples instead of lists

This commit is contained in:
Kodi Arfer 2019-08-02 14:48:06 -04:00
parent 52c0e4e221
commit 8576d00ce8

View File

@ -243,7 +243,7 @@ class HyComplex(HyObject, complex):
_wrappers[complex] = HyComplex _wrappers[complex] = HyComplex
class HySequence(HyObject, list): class HySequence(HyObject, tuple):
""" """
An abstract type for sequence-like models to inherit from. An abstract type for sequence-like models to inherit from.
""" """
@ -256,7 +256,8 @@ class HySequence(HyObject, list):
return self return self
def __add__(self, other): def __add__(self, other):
return self.__class__(super(HySequence, self).__add__(other)) return self.__class__(super(HySequence, self).__add__(
tuple(other) if isinstance(other, list) else other))
def __getslice__(self, start, end): def __getslice__(self, start, end):
return self.__class__(super(HySequence, self).__getslice__(start, end)) return self.__class__(super(HySequence, self).__getslice__(start, end))