[issue15402] Correct __sizeof__ support for struct
Martin v. Löwis
report at bugs.python.org
Thu Jul 26 22:03:49 CEST 2012
Martin v. Löwis <martin at v.loewis.de> added the comment:
> I do not think that the purpose of testing is a testing of object.__sizeof__.
> Memory consumption consists of two parts -- memory for C structure (and the
> base object implementation works for this)
Note that object.__sizeof__ does something slightly different, though:
it uses basicsize (which may or may not contain the sizeof() invocation
of the correct C structure), and it considers tp_itemsize (which may or
may not have a correct value).
>
>> I also realize that such tests will be fragile if the the structures
>> change. This is a good thing, IMO: anybody changing the layout of some
>> object should *have* to verify that the size computation is still correct,
>> so it's good that the test breaks if the structures change.
>
> Such tests is too fragile. They force the programmer to write unnecessary code
> in cases when it can be done automatically.
That's not the definition of "fragile", though. What you describe is
that writing the test this way is "tedious" (утомительный); it isn't
(necessarily) "fragile" (хрупкий). I (clearly) disagree that this
approach is "too tedious".
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15402>
_______________________________________
More information about the Python-bugs-list
mailing list