Message 155085 - Python tracker (original) (raw)

Case Van Horsen <report@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.