Re: gmpy adapter - Mailing list psycopg

From Daniele Varrazzo
Subject Re: gmpy adapter
Date
Msg-id AANLkTikhs6oaDr8S-=5+uT1urB2aGpV1P_vif=m=tSG6@mail.gmail.com
Whole thread Raw
In response to gmpy adapter  (Daniel Popowich <danielpopowich@gmail.com>)
Responses Re: gmpy adapter  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
List psycopg
On Mon, Feb 28, 2011 at 4:56 PM, Daniel Popowich
<danielpopowich@gmail.com> wrote:

>  1) Is there something I'm overlooking with gmpy that could make this
>     much simpler?

Why don't you use mpf instead? Arbitrary precision float may map
better than rationals to the database decimals.

>  2) What other solutions do folk use for working around pythons slow,
>     slow, slow Decimal?

There are around C implementations compatible with Python decimals:
http://www.bytereef.org/mpdecimal/index.html for example.

Also notice that float64 has 53 bits of precision, 15 full decimal
digits. If you don't need more precision when you write data in the
database (even if you have used more during calculations) you may just
use the repr(float()) of your mpq to write into the database.

-- Daniele

psycopg by date:

Previous
From: Daniele Varrazzo
Date:
Subject: Re: Using real libpq parameters
Next
From: Daniele Varrazzo
Date:
Subject: Re: gmpy adapter