summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-03-14 05:43:59 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-03-14 05:43:59 (GMT)
commit49f9bd15ffeef67358a319f89faeaa31ad97d575 (patch)
tree21a7a17750ea5dc4b7042b9f35085933b42d73d5 /Lib
parent6e2ee866fa5cac9de821921a31ad4ba76dfde8d9 (diff)
downloadcpython-49f9bd15ffeef67358a319f89faeaa31ad97d575.zip
cpython-49f9bd15ffeef67358a319f89faeaa31ad97d575.tar.gz
cpython-49f9bd15ffeef67358a319f89faeaa31ad97d575.tar.bz2
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.
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/test/test_array.py7
1 files changed, 7 insertions, 0 deletions
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 @@ 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