mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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:
parent
6e2ee866fa
commit
49f9bd15ff
4 changed files with 51 additions and 14 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue