[Bioperl-l] Re: issues with _rearrange

Steve Chervitz sac@bioperl.org
Thu, 19 Sep 2002 11:57:26 -0700 (PDT)


--- Aaron J Mackey <ajm6q@virginia.edu> wrote:
> 
> On Thu, 19 Sep 2002, Aaron J Mackey wrote:
> 
> > my ($self, @args) = @_;
> > my ($a1, $a2, $a3) = $self->_rearrange([qw(a1 a2 a3)], @args);
> >
> > becomes:
> >
> > my ($self, %args) = @_;
> > my ($a1, $a2, $a3) = @args{qw(a1 a2 a3)};
> 
> Before anyone jumps down my throat, I'm aware of all the -a1, -A1, A1, a1
> options that _rearrange handles; things are never completely as simple as
> we first believe them to be ;)
> 

Another thing to try is exporting _rearrange from RootI so that it can be used
as a class method, instead of an instance method, i.e., call it as _rearrange(
... ) rather than $self->_rearrange( ... ). This should improve performance.

I've always been concerned about all of the overhead from _rearrange calls, so
Aaron's suggestion seems reasonable to me. _rearrange is convenient, but maybe
it's a little *too* convenient. Allowing this much flexibility in specifying
method arguments is probably not necessary as many programmers and users are
accustomed to precisely defined arg lists. 

Typically, our method PODs state what the allowable arguments are without
stating that the hash keys are case-insensitive (and in some cases optional).
So I'd bet that most users don't know this flexibility exists and we're taking
a performance hit unnecessarily.

Before deprecating _rearrange, I'd be interested to know how much the class
function strategy improves performance, and how much not calling it at all
further improves it.


=====
Steve Chervitz
sac@bioperl.org

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com