New submission from Mark Dickinson <[EMAIL PROTECTED]>: The Python 3.0 version of decimal.py currently stores the coefficient of a Decimal number (or the payload of a NaN) as a string, all of whose characters are in the range '0' through '9'.
It may be more time-efficient to store the coefficient as a bytes instance instead, since bytes -> int conversion is likely to be faster than str -> int conversion. On the other hand, int -> bytes conversion has to go through str, so may be significantly slower than int -> str conversion... Bottom line: this needs testing. One other option: it may even be worth considering storing the coefficient directly as a Python integer. I've argued against this before, on the basis that it makes direct access to the decimal digits of a number harder, and this direct access is useful for rounding as well as for some of the more esoteric Decimal operations (logical operations, shifts and rotations). But it may be worth a look. (I think it's clear what the *right* option is, given unlimited developer time and energy: decimal.py should represent the coefficient using a long integer implementation written in C, with wordsize a power of 10---probably either 10**4 or 10**9.) See related discussion at issue 2482 and at http://mail.python.org/pipermail/python-dev/2008-March/078189.html ---------- components: Library (Lib) messages: 64521 nosy: facundobatista, marketdickinson, ncoghlan severity: normal status: open title: Consider using bytes type instead of str to store Decimal coefficients type: performance versions: Python 3.0 __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2486> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com