SF feature request #686323: Minor array module enhancements

array.extend() now accepts iterable arguments implements as a series
of appends.  Besides being a user convenience and matching the behavior
for lists, this the saves memory and cycles that would be used to
create a temporary array object.
This commit is contained in:
Raymond Hettinger 2004-03-14 05:43:59 +00:00
parent 6e2ee866fa
commit 49f9bd15ff
4 changed files with 51 additions and 14 deletions

View file

@ -592,6 +592,13 @@ class BaseTest(unittest.TestCase):
b = array.array(self.badtypecode())
self.assertRaises(TypeError, a.extend, b)
a = array.array(self.typecode, self.example)
a.extend(self.example[::-1])
self.assertEqual(
a,
array.array(self.typecode, self.example+self.example[::-1])
)
def test_coveritertraverse(self):
try:
import gc