Re: plpython3 - Mailing list pgsql-hackers

From Robert Haas
Subject Re: plpython3
Date
Msg-id 603c8f071002011020u23a6ba25ue2c9820c8f8916c6@mail.gmail.com
Whole thread Raw
In response to Re: plpython3  (James William Pye <lists@jwp.name>)
Responses Re: plpython3  ("Joshua D. Drake" <jd@commandprompt.com>)
Re: plpython3  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: plpython3  (Nathan Boley <npboley@gmail.com>)
Re: plpython3  ("Joshua D. Drake" <jd@commandprompt.com>)
List pgsql-hackers
On Sat, Jan 23, 2010 at 3:28 PM, James William Pye <lists@jwp.name> wrote:
> On Jan 14, 2010, at 7:08 PM, Greg Smith wrote:
>> So more targeted examples like you're considering now would help.
>
> Here's the trigger example which should help reveal some of the advantages of "native typing". This is a generic
triggerthat constructs and logs manipulation statements for simple replication purposes. 
>
> The original plpython version is located here:
>
>  http://ar.pycon.org/common/2009/talkdata/PyCon2009/020/plpython.txt
>  [You'll need to scroll down to the very bottom of that page.]
>
>
> There are three points in this example that need to be highlighted:
>
>  1. There is no need for a "mogrify" function (see original in the above link).
>  2. Attributes/columns of the records (new/old) are extracted when referenced.
>  3. The comparisons in after_update uses the data type's actual inequality operator.
>
> The first point is true because "native typing" gives the user direct access to a given type's typoutput via
``str(ob)``.This makes constructing the PG string representation of a given object *much* easier--quote_nullable, and
done.The original plpython example will need to be updated to compensate for any changes in conversion: arrays will now
needspecial handling and MD arrays will not work at all. It also relies heavily on the Python object representation
matchingPG's; where that fails, special cases need to be implemented(composites, notably). All of that compensation
performedin the original version is unnecessary in the plpython3 version. 
>
> The second point touches on the "efficiency" that was referenced in an earlier message. No cycles are spent
convertingthe contents of a container object unless the user chooses to. Naturally, there is no advantage
performance-wiseif you are always converting everything. 
> I'd wager that with triggers, it's rare that everything needs to be converted.
>
> The third point reveals that Postgres.Object instances--a component of native typing--use the data type's operator
forinequality. It's not limited to comparisons as all available Python operators are mapped to corresponding operators
inPG. For many or all primitives, there is no added value over conversion. However, this provides a lot of convenience
whenworking with UDTs, datetime types, and geometric types. 
>
> ...ISTM that the primary advantage of "native typing" is that we get to define the Python interface to a given
Postgresdata type. 

When I initially read the description of this patch, I had really no
idea what it was about, and I have to say that over the last several
weeks, the subsequent posts have increased my interest substantially,
and I think it could potentially have a future in core, or in contrib.The performance gains from native typing are
particularly
interesting.

That having been said, we don't have a reviewer for this patch, and
more to the point, even if we did, I don't believe we have a COMMITTER
for this patch.  The only committer who has done any significant work
on the existing PL/python implementation for this release is Peter
Eisentraut, and he's made it pretty clear that he's not interested in
this reimplementation.  I personally do not know Python even as a
user, let alone as a hacker, so I'm poorly qualified to review it
myself.  Even were it otherwise, I know that if I were to commit this
I would to some degree be on the hook to maintain it forever, which is
more than I really want to take on.  I suspect other committers feel
similarly; or if not, they haven't chimed in on any of the relevant
threads to say so.

To recap the votes I've seen on this thread and elsewhere:

- JD is very enthusiastic about this patch
- So is the OP
- Josh Berkus and I are both dubious about having two in-core PL/pythons
- Peter Eisentraut prefers the original implementation
- Greg Smith thinks (if I'm not putting words into his mouth) that
this might be worth considering, but not for 9.0

On the basis of all of the foregoing, I don't think we can consider
this patch further for this CommitFest and will update
commitfest.postgresql.org accordingly.  If the user community grows or
if one of the committers takes an interest in this down the road, I
think we could consider it for a future release.

...Robert


pgsql-hackers by date:

Previous
From: M Z
Date:
Subject: Re: contrib\xml2 package's xpath_table function in PostgreSQL
Next
From: Robert Haas
Date:
Subject: Re: contrib\xml2 package's xpath_table function in PostgreSQL