>>9 Of course it is. You can see easily within a few minutes:
time perl -e 'print join(",", (1...16553600));' >/dev/null
and
time perl -e 'print join(",", reverse(1...16553600));' >/dev/null
complete in the same amount of time here. Of course, for sets this large using @lists
is usually a mistake anyway.
>>10 Looks better, although it has the same deficiency mine had which requires other code to treat []
and undef
as the same specially which I don't like. Oh well.
You may enjoy knowing that I did some tests with large sets, and it looks like the slice operation with all the pop
s on your sub list
uses a lot more memory and is noticeably slower than mine. This makes sense: pp_reverse
keeps the list operations entirely in cache whereas the path to av_pop
is long enough that it requires extra memory accesses, which is in-turn combined with the (relatively) slow pp_aslice
.