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.
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index c9b05c2..0f3e07f 100755
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -592,6 +592,13 @@
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