Issue #15424: Add a __sizeof__ implementation for array objects.

Patch by Ludwig Hähne.
This commit is contained in:
Meador Inge 2012-08-10 22:35:45 -05:00
parent 7dbee38564
commit 03b4d5072a
4 changed files with 32 additions and 0 deletions

View file

@ -988,6 +988,19 @@ class BaseTest(unittest.TestCase):
a = array.array('H', b"1234")
self.assertEqual(len(a) * a.itemsize, 4)
@support.cpython_only
def test_sizeof_with_buffer(self):
a = array.array(self.typecode, self.example)
basesize = support.calcvobjsize('4Pi')
buffer_size = a.buffer_info()[1] * a.itemsize
support.check_sizeof(self, a, basesize + buffer_size)
@support.cpython_only
def test_sizeof_without_buffer(self):
a = array.array(self.typecode)
basesize = support.calcvobjsize('4Pi')
support.check_sizeof(self, a, basesize)
class StringTest(BaseTest):