mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #19087: Improve bytearray allocation in order to allow cheap popping of data at the front (slice deletion).
This commit is contained in:
parent
dcd01b4932
commit
5df8a8a1fd
5 changed files with 182 additions and 151 deletions
|
@ -909,6 +909,15 @@ class ByteArrayTest(BaseBytesTest, unittest.TestCase):
|
|||
with self.assertRaises(ValueError):
|
||||
b[3:4] = elem
|
||||
|
||||
def test_setslice_extend(self):
|
||||
# Exercise the resizing logic (see issue #19087)
|
||||
b = bytearray(range(100))
|
||||
self.assertEqual(list(b), list(range(100)))
|
||||
del b[:10]
|
||||
self.assertEqual(list(b), list(range(10, 100)))
|
||||
b.extend(range(100, 110))
|
||||
self.assertEqual(list(b), list(range(10, 110)))
|
||||
|
||||
def test_extended_set_del_slice(self):
|
||||
indices = (0, None, 1, 3, 19, 300, 1<<333, -1, -2, -31, -300)
|
||||
for start in indices:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue