[issue25421] Make __sizeof__ for builtin types more subclass friendly

2015-12-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Committed with improved tests.

--
assignee:  -> serhiy.storchaka
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions:  -Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25421] Make __sizeof__ for builtin types more subclass friendly

2015-12-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you David. Looks related to alignment. Hope this will help.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25421] Make __sizeof__ for builtin types more subclass friendly

2015-12-19 Thread R. David Murray

R. David Murray added the comment:

At least some of the buildbots aren't happy.

http://buildbot.python.org/all/builders/ARMv7%20Ubuntu%203.5/builds/479/steps/test/logs/stdio

http://buildbot.python.org/all/builders/ARMv7%20Ubuntu%202.7/builds/1077/steps/test/logs/stdio

http://buildbot.python.org/all/builders/AMD64%20FreeBSD%209.x%202.7/builds/1098/steps/test/logs/stdio

--
nosy: +r.david.murray
status: closed -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25421] Make __sizeof__ for builtin types more subclass friendly

2015-12-19 Thread Roundup Robot

Roundup Robot added the comment:

New changeset a1388dbdd293 by Serhiy Storchaka in branch '3.5':
Use correct PyGC_Head size in tests for issue #25421.
https://hg.python.org/cpython/rev/a1388dbdd293

New changeset ab97ff838e11 by Serhiy Storchaka in branch '2.7':
Use correct PyGC_Head size in tests for issue #25421.
https://hg.python.org/cpython/rev/ab97ff838e11

New changeset 5115f39cc59f by Serhiy Storchaka in branch 'default':
Use correct PyGC_Head size in tests for issue #25421.
https://hg.python.org/cpython/rev/5115f39cc59f

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25421] Make __sizeof__ for builtin types more subclass friendly

2015-12-19 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 71d6755145ae by Serhiy Storchaka in branch '3.5':
Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size.
https://hg.python.org/cpython/rev/71d6755145ae

New changeset 4a47e998c40a by Serhiy Storchaka in branch 'default':
Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size.
https://hg.python.org/cpython/rev/4a47e998c40a

New changeset be3998aed1e7 by Serhiy Storchaka in branch '2.7':
Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size.
https://hg.python.org/cpython/rev/be3998aed1e7

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25421] Make __sizeof__ for builtin types more subclass friendly

2015-12-19 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25421] Make __sizeof__ for builtin types more subclass friendly

2015-10-16 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
nosy: +pitrou

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25421] Make __sizeof__ for builtin types more subclass friendly

2015-10-16 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Default __sizeof__() implementation uses tp_basicsize. This makes it to work 
correctly with most builtin types and types with __slots__ (using __slots__ 
increases tp_basicsize). But special implementations of __sizeof__() use static 
object size ('sizeof(XXXObject)'), and return incorrect result for subclasses 
that increase tp_basicsize. Proposed patch makes __sizeof__() for all 
subclassable builtin type that support changing object size (i.e. tp_itemsize 
== 0) to use dynamic size _PyObject_SIZE(Py_TYPE(self)).

Example (with patched code):
>>> class D(dict):
... __slots__ = 'a', 'b', 'c'
... 
>>> sys.getsizeof({})
144
>>> sys.getsizeof(D())
156

In unpatched Python sys.getsizeof(D()) returns 144.

--
components: Extension Modules, Interpreter Core
files: sizeof_dynamic.patch
keywords: patch
messages: 253074
nosy: serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Make __sizeof__ for builtin types more subclass friendly
type: behavior
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file40795/sizeof_dynamic.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com