Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue25421

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:Make __sizeof__ for builtin types more subclass friendly
Type:behaviorStage:resolved
Components:Extension Modules, Interpreter CoreVersions:Python 3.6, Python 3.5, Python 2.7
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To: serhiy.storchakaNosy List: pitrou, python-dev, r.david.murray, serhiy.storchaka
Priority:normalKeywords:patch

Created on2015-10-16 16:42 byserhiy.storchaka, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
sizeof_dynamic.patchserhiy.storchaka,2015-10-16 16:41review
Messages (6)
msg253074 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2015-10-16 16:41
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())156In unpatched Python sys.getsizeof(D()) returns 144.
msg256734 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2015-12-19 18:08
New changeset71d6755145ae 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/71d6755145aeNew changeset4a47e998c40a by Serhiy Storchaka in branch 'default':Issue#25421: __sizeof__ methods of builtin types now use dynamic basic size.https://hg.python.org/cpython/rev/4a47e998c40aNew changesetbe3998aed1e7 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
msg256735 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2015-12-19 18:13
Committed with improved tests.
msg256737 -(view)Author: R. David Murray (r.david.murray)*(Python committer)Date: 2015-12-19 19:08
At least some of the buildbots aren't happy.http://buildbot.python.org/all/builders/ARMv7%20Ubuntu%203.5/builds/479/steps/test/logs/stdiohttp://buildbot.python.org/all/builders/ARMv7%20Ubuntu%202.7/builds/1077/steps/test/logs/stdiohttp://buildbot.python.org/all/builders/AMD64%20FreeBSD%209.x%202.7/builds/1098/steps/test/logs/stdio
msg256738 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2015-12-19 20:51
New changeseta1388dbdd293 by Serhiy Storchaka in branch '3.5':Use correct PyGC_Head size in tests for issue#25421.https://hg.python.org/cpython/rev/a1388dbdd293New changesetab97ff838e11 by Serhiy Storchaka in branch '2.7':Use correct PyGC_Head size in tests for issue#25421.https://hg.python.org/cpython/rev/ab97ff838e11New changeset5115f39cc59f by Serhiy Storchaka in branch 'default':Use correct PyGC_Head size in tests for issue#25421.https://hg.python.org/cpython/rev/5115f39cc59f
msg256739 -(view)Author: Serhiy Storchaka (serhiy.storchaka)*(Python committer)Date: 2015-12-19 20:52
Thank you David. Looks related to alignment. Hope this will help.
History
DateUserActionArgs
2022-04-11 14:58:22adminsetgithub: 69607
2015-12-20 07:27:55serhiy.storchakasetstatus: open -> closed
2015-12-19 20:52:33serhiy.storchakasetmessages: +msg256739
2015-12-19 20:51:26python-devsetmessages: +msg256738
2015-12-19 19:08:32r.david.murraysetstatus: closed -> open
nosy: +r.david.murray
messages: +msg256737

2015-12-19 18:13:45serhiy.storchakasetstatus: open -> closed
versions: - Python 3.4
messages: +msg256735

assignee:serhiy.storchaka
resolution: fixed
stage: patch review -> resolved
2015-12-19 18:08:30python-devsetnosy: +python-dev
messages: +msg256734
2015-10-17 03:20:04rhettingersetnosy: +pitrou
2015-10-16 16:42:00serhiy.storchakacreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp