Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 76F4C133616B for ; Thu, 28 Oct 2010 15:41:45 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 74971-05 for ; Thu, 28 Oct 2010 18:41:38 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from cdptpa-omtalb.mail.rr.com (cdptpa-omtalb.mail.rr.com [75.180.132.121]) by mail.postgresql.org (Postfix) with ESMTP id C5C0A1335B36 for ; Thu, 28 Oct 2010 15:41:37 -0300 (ADT) X-Authority-Analysis: v=1.1 cv=pepdxKapwHuwCZNFD5uob2wvham6E+RljB0uXw08FdQ= c=1 sm=0 a=8nJEP1OIZ-IA:10 a=qCTYjJJ2g1SgQhsHZAUATw==:17 a=SMYb-vVDOJGuV9BnjLwA:9 a=OevbfcGsrbEtuPdeRm4A:7 a=D5QC383fORt8szLf2is2n0UUNbAA:4 a=wPNLvfGTeEIA:10 a=qCTYjJJ2g1SgQhsHZAUATw==:117 X-Cloudmark-Score: 0 X-Originating-IP: 98.27.48.207 Received: from [98.27.48.207] ([98.27.48.207:39365] helo=[192.168.10.104]) by cdptpa-oedge03.mail.rr.com (envelope-from ) (ecelerity 2.2.3.46 r()) with ESMTP id FA/FB-19545-1E3C9CC4; Thu, 28 Oct 2010 18:41:37 +0000 Message-ID: <4CC9C3E0.4000706@dunslane.net> Date: Thu, 28 Oct 2010 14:41:36 -0400 From: Andrew Dunstan User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100907 Fedora/3.1.3-1.fc13 Lightning/1.0b3pre Thunderbird/3.1.3 MIME-Version: 1.0 To: Garick Hamlin CC: Tom Lane , Pavel Stehule , PostgreSQL-development , Tim Bunce Subject: Re: plperl arginfo References: <4CC995C2.3000704@dunslane.net> <16686.1288280351@sss.pgh.pa.us> <4CC9A4E2.9050604@dunslane.net> <20300.1288283668@sss.pgh.pa.us> <4CC9ACDC.9090508@dunslane.net> <20101028181105.GA15019@isc.upenn.edu> In-Reply-To: <20101028181105.GA15019@isc.upenn.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201010/2001 X-Sequence-Number: 173041 On 10/28/2010 02:11 PM, Garick Hamlin wrote: > On Thu, Oct 28, 2010 at 01:03:24PM -0400, Andrew Dunstan wrote: >> >> On 10/28/2010 12:34 PM, Tom Lane wrote: >>> BTW, maybe we could have the best of both worlds? Dunno about Perl, >>> but in some languages it would be possible to instantiate the hash >>> only if it's actually touched. Passing the data as a hash definitely >>> seems to fit with the spirit of things otherwise, so as long as it >>> didn't cost cycles when not needed, I'd be in favor of that API. >> Maybe, but I think that's getting rather beyond my perlguts-fu. I think >> we'd need to do that via PERL_MAGIC_tied, but it's new territory for me. >> Anyone else want to chime in? > Warning, I don't know the plperl, I am just a perl coder. > > I do think all the anonymous array are worth worrying about in terms of > performance. > > I don't think that tie is necessarily good for performance. tie() is not > generally fast. I think you'd likely be better off writing plain accessors > or using a function to add type info. > > Use an accessor for type information, like this? > $ref->typeof($key) > > ... > or perhaps use a special function? > > add_type_info(\%args); > > ... > or if you want attibute based syntax sugar for the add_type_info() solution... > > my %args : pg_record(add_type_info); > > Again, these I don't know the plperl code, so I might be missing something > here. > This wouldn't be done at the perl level. It would be done in C code. Run "man perlguts" and search for "Understanding the Magic of Tied Hashes and Arrays". The overhead in setting it up is likely to be very low unless I'm not understanding correctly. There might be some price paid when accessing the object, but that's another affair. OTOH, a pg_get_arg_info() function would probably be a substantially simpler if slightly less perlish solution. cheers andrew