[issue7652] Merge C version of decimal into py3k.

Stefan Krah report at bugs.python.org
Wed Mar 7 14:23:00 CET 2012


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

Case Van Horsen <report at bugs.python.org> wrote:
> cdecimal 2.3 does not support the __ceil__ and __floor__

Thanks. I'll look into that.

> cdecimal.Decimal instances do not emulate the various single-underscore methods of a decimal.Decimal instance. In gmpy2, I use _int, _exp, _sign, and _is_special to convert a decimal.Decimal into an exact fraction. I realize the issue is with gmpy2 and I will fix gmpy2, but there may be other code that uses those methods.

There seems to be a real need for getting (sign, coeff, exp). I think
psycopg2 uses a painful way to get an integer coefficient via as_tuple().
What should really be added is either as_triple(), which would return
(sign, coeff, exp) with an integer coefficient or make these attributes
official:

Decimal.sign
Decimal.coeff
Decimal.exp

I have to think about implementing Decimal._int etc. Somehow I feel that
doing so would send a wrong signal: People shouldn't assume that they'll
get away with using private methods and attributes.

Also, of course they'll keep using these private methods until they
are finally deprecated, and *then* they'll have to change things.

----------

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


More information about the Python-bugs-list mailing list