Re: Problem with the default registration of the JSON adapter - Mailing list psycopg

From Federico Di Gregorio
Subject Re: Problem with the default registration of the JSON adapter
Date
Msg-id 51ED4DDA.4090809@dndg.it
Whole thread Raw
In response to Re: Problem with the default registration of the JSON adapter  (Christophe Pettus <xof@thebuild.com>)
Responses Re: Problem with the default registration of the JSON adapter  (Christophe Pettus <xof@thebuild.com>)
List psycopg
On 22/07/2013 17:02, Christophe Pettus wrote:
>
> On Jul 22, 2013, at 2:04 AM, Federico Di Gregorio wrote:
>> IMO, dropping authomatic registration in the next minor release and
>> having users explicitly calling register_json() is better.
>
> You don't have to register TEXT; why would you have to register JSON?

Because with TEXT and DECIMAL and FLOAT and all the base types that have
d direct 1-on-1 mapping to Python you don't have a choice. In more than
10 years of psycopg nobody ever asked «can I please get the floats as
text instead of Python float objects?».

JSON is different because the representation you get is exactly the
representation you may want to send to the the client (probably over
HTTP) and the conversion text->json objects->text uses quite a bit of
cpu/memory. So it does make sense to make it either opt-in or opt-out.
Given that psycopg never had opt-out adapters/typecasters my vote is to
make it opt-in.

federico




psycopg by date:

Previous
From: Christophe Pettus
Date:
Subject: Re: Problem with the default registration of the JSON adapter
Next
From: Christophe Pettus
Date:
Subject: Re: Problem with the default registration of the JSON adapter