gmpy/decimal interoperation

Alex Martelli aleax at mail.comcast.net
Sun Nov 13 20:03:23 EST 2005


As things stand now (gmpy 1.01), an instance d of decimal.Decimal cannot
transparently become an instance of any of gmpy.{mpz, mpq, mpf}, nor
vice versa (the conversions are all possible, but a bit laborious, e.g.
by explicitly going through string-forms).

I'm thinking about possible ways to fix this, in whole or in part, but,
before I spend more time on this, I was wondering if there's anybody
else who'd be interested -- if so, maybe we can discuss which
conversions should happen implicitly (e.g., if you try to sum a Decimal
and an mpz, maybe the latter should implicitly become a Decimal, just
like an int would, so that the result is a Decimal) and which ones
should only happen on explicit request (e.g., gmpy.mpf(d) should produce
an mpf instance, just as calling gmpy.mpf on an int instance would).


Alex



More information about the Python-list mailing list