classification
Title: Default __sizeof__ is wrong for var-sized objects
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.5, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: pitrou, python-dev, serhiy.storchaka, skrah
Priority: normal Keywords: patch

Created on 2015-03-10 15:44 by pitrou, last changed 2015-03-10 21:41 by pitrou. This issue is now closed.

Files
File name Uploaded Description Edit
sizeof_var_obj.patch pitrou, 2015-03-10 15:44 review
Messages (6)
msg237776 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2015-03-10 15:44
In the stdlib, this only appears with the memoryview object, but third-party types can be affected. Attaching patch.
msg237783 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-03-10 17:28
Good catch! How it worked before?

Now we can remove __sizeof__ implementations for tuples and bytes.

Could you please add sizeof test for PyStructSequence types?
msg237799 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-03-10 19:18
Ah, tests for PyStructSequence types already exist (tests for sys.flags and sys.float_info).

The patch LGTM.
msg237811 - (view) Author: Roundup Robot (python-dev) Date: 2015-03-10 21:37
New changeset f9afa4f87570 by Antoine Pitrou in branch '3.4':
Issue #23629: Fix the default __sizeof__ implementation for variable-sized objects.
https://hg.python.org/cpython/rev/f9afa4f87570

New changeset 9994e0172a0c by Antoine Pitrou in branch 'default':
Issue #23629: Fix the default __sizeof__ implementation for variable-sized objects.
https://hg.python.org/cpython/rev/9994e0172a0c
msg237812 - (view) Author: Roundup Robot (python-dev) Date: 2015-03-10 21:41
New changeset dbd48b22b477 by Antoine Pitrou in branch '2.7':
Issue #23629: Fix the default __sizeof__ implementation for variable-sized objects.
https://hg.python.org/cpython/rev/dbd48b22b477
msg237813 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2015-03-10 21:41
Good, committed.
History
Date User Action Args
2015-03-10 21:41:45pitrousetstatus: open -> closed
resolution: fixed
messages: + msg237813

stage: patch review -> resolved
2015-03-10 21:41:30python-devsetmessages: + msg237812
2015-03-10 21:37:43python-devsetnosy: + python-dev
messages: + msg237811
2015-03-10 19:18:39serhiy.storchakasetmessages: + msg237799
2015-03-10 17:41:41pitrousetversions: + Python 2.7
2015-03-10 17:28:44serhiy.storchakasetmessages: + msg237783
2015-03-10 15:44:31pitrousetfiles: + sizeof_var_obj.patch
keywords: + patch
2015-03-10 15:44:19pitroucreate