in reply to Re: Miniature golf question
in thread Miniature golf question
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:
If it takes a while, you aren't on 5.6.1 yet. :-)my @big_list = map {($_, $_)} 1..50_000;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re (tilly) 2: Miniature golf question
by nysus (Parson) on Jul 17, 2001 at 07:30 UTC |