in reply to returning large arrays from functions
Perl does not employ a copy-on-write mechanism. As such, assigning a one array to another (as in the second example) involves copying the elements, not just copying a reference to the elements.
In the first example, you're not even assigning an array to an array. You're getting a list of the elements in the array, then you're assigning that list to another array. You might end up copying each element twice! I know there's at least one optimisation in place, but there's no escaping copying each element at least once for the reason I gave above.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: returning large arrays from functions
by Anonymous Monk on Nov 19, 2010 at 06:54 UTC | |
by ikegami (Patriarch) on Nov 19, 2010 at 07:55 UTC | |
by Anonymous Monk on Nov 19, 2010 at 08:14 UTC | |
by ikegami (Patriarch) on Nov 19, 2010 at 08:22 UTC | |
by Anonymous Monk on Nov 19, 2010 at 09:27 UTC | |
|