[issue14520] Buggy Decimal.__sizeof__

Stefan Krah report at bugs.python.org
Mon Apr 9 18:54:38 CEST 2012


Stefan Krah <stefan-usenet at bytereef.org> added the comment:

Mark Dickinson <report at bugs.python.org> wrote:
> In the C version of decimal, do distinct Decimal objects ever share coefficients?

The coefficients are members of the mpd_t struct (libmpdec data type),
and they are not exposed as Python objects or shared.

Cache locality is incredibly important: I have a patch that reserves
a static coefficient of four words inside the PyDecObject. This patch
speeds up _decimal by roughly another 30-40% for regularly sized decimals.

If the decimal grows beyond that, libmpdec automatically switches to
a dynamically allocated coefficient.

I think sharing would probably slow things down a bit.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14520>
_______________________________________


More information about the Python-bugs-list mailing list