in reply to Re: Miniature golf question
in thread Miniature golf question

Your efficiency note is only true until Perl 5.6.1.

The problem is that Perl builds the return list in place. In old versions it would only allocate the minimum necessary space, moving data every time. The moving of data was a O(n2) bottleneck. Starting in 5.6.1 it will allocate the minimum of the minimum necessary, and the length of the data stack. This results in a power of 2 reallocation strategy that winds up being O(n) in terms of moving data.

To experience the difference that this makes, try running this statement in both a new and old version of Perl:

my @big_list = map {($_, $_)} 1..50_000;
If it takes a while, you aren't on 5.6.1 yet. :-)

Replies are listed 'Best First'.
Re: Re (tilly) 2: Miniature golf question
by nysus (Parson) on Jul 17, 2001 at 07:30 UTC
    Tilly, I started to read "Structure and Interpretations of Computer Programs" and it was right around the stuff you bring up above that I started to get lost. Too much for a guy who blew off H.S. more than he should have. So until I brush up on my math skills, do you know of a lighter introduction to the kind of concepts you mention above? Thanks, bro.

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop";
    $nysus = $PM . $MCF;
    Click here if you love Perl Monks