Message64521
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 |
|
| Date |
User |
Action |
Args |
| 2008-03-25 21:36:15 | marketdickinson | set | spambayes_score: 0.00645705 -> 0.00645705 recipients:
+ marketdickinson, facundobatista, ncoghlan |
| 2008-03-25 21:36:15 | marketdickinson | set | spambayes_score: 0.00645705 -> 0.00645705 messageid: <1206480975.35.0.923616350386.issue2486@psf.upfronthosting.co.za> |
| 2008-03-25 21:36:14 | marketdickinson | link | issue2486 messages |
| 2008-03-25 21:36:13 | marketdickinson | create | |
|