[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17120] trunk/blender/source/blender/ python/api2_2x: === Blender Python API ===

Nathan Letwory jesterking at letwory.net
Mon Oct 20 08:29:02 CEST 2008


On Mon, Oct 20, 2008 at 3:09 AM, Campbell Barton <ideasman42 at gmail.com> wrote:
> Could it be better to add the __sizeof__() function to these types?
>
> Python already has __sizeof__ and its not used for internal functions
> so adding it would not break anything.
>
> To copy pythons
> int.__sizeof__(1) -> type(mesh).__sizeof__(mesh)
>
> or in py 2.6 ... sys.getsizeof()
> http://www.python.org/doc/2.6/library/sys.html#sys.getsizeof
>
> Also interested in how your using this function.

Hmm, I was thinking of that, but using __sizeof__ would imo imply more
the bpy level of size. What I'm getting at here is the size for
underlying structs.

Anyway, the point is here to get the sizeof underlying structs so they
keep always up-to-date all the way through to the BPy API. This is a
much better way then using magic numbers for these struct sizes, as
they will go out of sync when someone fiddles with the sDNA. These
sizeof()s are used for estimating memory usage.

Looking into using __sizeof__() instead of DataSize() (which doesn't
break anything either ;)

/Nathan


More information about the Bf-committers mailing list