Re: Problem with the default registration of the JSON adapter

From: Federico Di Gregorio <fog(at)dndg(dot)it>
To: psycopg(at)postgresql(dot)org
Subject: Re: Problem with the default registration of the JSON adapter
Date: 2013-07-22 15:20:58
Message-ID: 51ED4DDA.4090809@dndg.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Christophe Pettus 2013-07-22 15:55:47 Re: Problem with the default registration of the JSON adapter
Previous Message Christophe Pettus 2013-07-22 15:02:57 Re: Problem with the default registration of the JSON adapter