A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2003-January/032601.html below:

[Python-Dev] PEP 42: sizeof(obj) builtin

[Python-Dev] PEP 42: sizeof(obj) builtinTim Peters tim.one@comcast.net
Thu, 30 Jan 2003 19:44:59 -0500
[Raymond Hettinger]
> I'm about to start working on this one and wanted
> to check here first to make sure there is still a
> demand for it and to get ideas on the best implementation
> strategy.

Marc-Andre implemented it for mxTools:

    http://www.lemburg.com/files/python/mxTools.html

    sizeof(object)

    Returns the number of bytes allocated for the given Python object.
    Additional space allocated by the object and stored in pointers is not
    taken into account (though the pointer itself is). If the object
    defines tp_itemsize in its type object then it is assumed to be a
    variable size object and the size is adjusted accordingly.

I don't know whether anyone finds it useful in real life; maybe MAL has an
idea about that.


> I'm thinking of summing all of the tp_basicsize slots
> while recursing through tp_traverse.

So you'd add in the size of 0.0 a million times when traversing

    [0.0] * 1000000

?  That wouldn't be useful.  Keeping a memo to avoid double-counting might
be useful, but then it also gets more complicated, and so much better to
write it in Python building on something straighforward like mxTool's
version.




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4