This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients Somelauw, benjamin.peterson, jyasskin, mark.dickinson, rhettinger
Date 2009-01-20.17:52:38
SpamBayes Score 3.2891467e-08
Marked as misclassified No
Message-id <1232473960.36.0.519183388347.issue4998@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2009-01-20 17:52:40mark.dickinsonsetrecipients: + mark.dickinson, rhettinger, jyasskin, benjamin.peterson, Somelauw
2009-01-20 17:52:40mark.dickinsonsetmessageid: <1232473960.36.0.519183388347.issue4998@psf.upfronthosting.co.za>
2009-01-20 17:52:39mark.dickinsonlinkissue4998 messages
2009-01-20 17:52:38mark.dickinsoncreate