Having no time to write and/or maintain RFC's, I'll toss this up in the air
and see what happens.

Abigail has posted sorting benchmarks for 5.6.0 to 5.7.0 on clp.misc, and I've
extended that being curious to performance loss for anonymous blocks and named
subroutines

        sub Xcmp { $a cmp $b }
        
        @a = sort               @x;     # Internal sorting
        @a = sort { $a cmp $b } @x;     # sorting through block
        @a = sort     Xcmp      @x;     # Sorting with named sub

I've posted the results (stunning) to p5p and the Amsterdam.pm mailing lists
for perl5.005.03, perl5.6.0 and perl5.7.0.

Just out of curiopusity someone on amsterdam.pm asked:
> > Which shows a *HUGE* difference between 5.005.03 and 5.6.0 for the diff
> > between named subs (in 5.6.0 almost as fast as internal, sometimes even faster)
> > and anonymous blocks (in 5.005.03 almost as slow as named subs).
> > 
> > Whoosh, has 5.6.0 been some improvement in optimizing anonymous blocks!
> 
> See, this is exactly the kind of thing I'm better off not knowing.  Do 
> you think I'll be able to stop myself from using anonymous blocks given 
> how much faster they are?  Nee, naturlijk.
> 
> However I would argue that anonymous blocks are often a bad thing for 
> code maintenance.  I don't have Algorithm::Numerical::Shuffle handy - 
> do you think I could convince you to run this benchmark again using 
> subroutine references?
> 
> That is:
> 
> my $Ycmp = { $a cmp $b };
> 
> I'm just curious.

She meant of course:

        my $Ycmp = sub { $a cmp $b };
        @a = sort $Ycmp @x;

but this is an unsupported syntax for sort.

Is it feasable/useful to extend sort's syntax in supporting sub ref's?

-- 
H.Merijn Brand           Amsterdam Perl Mongers (http://www.amsterdam.pm.org/)
using perl5.005.03, 5.6.0 & 516 on HP-UX 10.20, HP-UX 11.00, AIX 4.2, AIX 4.3,
     DEC OSF/1 4.0 and WinNT 4.0 SP-6a,  often with Tk800.022 and/or DBD-Unify
ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/id/H/HM/HMBRAND/

Reply via email to