mirror of
https://github.com/python/cpython.git
synced 2025-08-24 10:45:53 +00:00
Issue #15424: Add a __sizeof__ implementation for array objects.
Patch by Ludwig Hähne.
This commit is contained in:
parent
7dbee38564
commit
03b4d5072a
4 changed files with 32 additions and 0 deletions
|
@ -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):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue