Message80261
A random data point: just for fun, I just tried assessing the impact of
__slots__ on Decimal instances, by the crude method of putting all of the
Decimal instances that are created during a complete run of the Decimal
test suite (over 100000 of them) into a list and watching memory usage.
This was on a non-debug 32-bit build of py3k, with 16-bit Py_UNICODE
(which is relevant because the coefficients of Decimal instances are
strings).
Results: (*)
~44 bytes per Decimal on average with __slots__
~183 bytes per Decimal on average without __slots__
The effect on speed wasn't really significant: removing __slots__ gives
at worst a 1-2% slowdown on a complete run of the test-suite.
So please let's not remove __slots__ from Fraction!
(*) raw numbers: 120343 total number of Decimals. The following
are memory readings from the RSIZE column of top.
with __slots__:
putting 8 copies of each Decimal into list -> 33M total usage
putting 4 copies of each Decimal into list -> 55M total usage
without __slots__:
putting 8 copies of each Decimal into list -> 182M total usage
putting 4 copies of each Decimal into list -> 96M total usage.
I took the liberty of subtracting 4 bytes per list entry, to compensate
for the memory taken by the list itself. |
|
Date |
User |
Action |
Args |
2009-01-20 17:52:40 | mark.dickinson | set | recipients:
+ mark.dickinson, rhettinger, jyasskin, benjamin.peterson, Somelauw |
2009-01-20 17:52:40 | mark.dickinson | set | messageid: <1232473960.36.0.519183388347.issue4998@psf.upfronthosting.co.za> |
2009-01-20 17:52:39 | mark.dickinson | link | issue4998 messages |
2009-01-20 17:52:38 | mark.dickinson | create | |
|