[Python-ideas] Bad programming style in decorators?
Serhiy Storchaka
storchaka at gmail.com
Sun Jan 3 06:55:36 EST 2016
On 03.01.16 04:42, Nick Coghlan wrote:
> Finally, we get to the question of relative size: are function
> instances larger or smaller than your typical class instance? Again,
> we don't have to guess, we can use the interpreter to experiment and
> check our assumptions:
>
> >>> import sys
> >>> def f(): pass
> ...
> >>> sys.getsizeof(f)
> 136
> >>> class C(): pass
> ...
> >>> sys.getsizeof(C())
> 56
sys.getsizeof() returns only the bare size of the object, not including
the size of subobjects. To calculate total size you have to sum sizes of
all subobjects recursively. [1]
[1] http://bugs.python.org/file31822/gettotalsizeof.py
More information about the Python-ideas
mailing list