Skip site navigation (1) Skip section navigation (2)

Re: plpython3

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: James William Pye <lists(at)jwp(dot)name>
Cc: Greg Smith <greg(at)2ndquadrant(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, jd(at)commandprompt(dot)com, Josh Berkus <josh(at)agliodbs(dot)com>, PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: plpython3
Date: 2010-02-01 18:20:47
Message-ID: 603c8f071002011020u23a6ba25ue2c9820c8f8916c6@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
On Sat, Jan 23, 2010 at 3:28 PM, James William Pye <lists(at)jwp(dot)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 trigger that 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 need special handling and MD arrays will not work at all. It also relies heavily on the Python object representation matching PG's; where that fails, special cases need to be implemented(composites, notably). All of that compensation performed in 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 converting the contents of a container object unless the user chooses to. Naturally, there is no advantage performance-wise if 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 for inequality. It's not limited to comparisons as all available Python operators are mapped to corresponding operators in PG. For many or all primitives, there is no added value over conversion. However, this provides a lot of convenience when working 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 Postgres data 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

In response to

Responses

pgsql-hackers by date

Next:From: Robert HaasDate: 2010-02-01 18:23:33
Subject: Re: contrib\xml2 package's xpath_table function in PostgreSQL
Previous:From: M ZDate: 2010-02-01 18:20:11
Subject: Re: contrib\xml2 package's xpath_table function in PostgreSQL

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group