Re: gmpy adapter

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: Daniel Popowich <danielpopowich(at)gmail(dot)com>
Cc: psycopg(at)postgresql(dot)org
Subject: Re: gmpy adapter
Date: 2011-02-28 23:07:39
Message-ID: AANLkTikhs6oaDr8S-=5+uT1urB2aGpV1P_vif=m=tSG6@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On Mon, Feb 28, 2011 at 4:56 PM, Daniel Popowich
<danielpopowich(at)gmail(dot)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

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Daniele Varrazzo 2011-03-01 10:19:55 Re: gmpy adapter
Previous Message Daniele Varrazzo 2011-02-28 21:27:46 Re: Using real libpq parameters