Lisp (16)

11 Name: #!/usr/bin/anonymous : 2007-12-28 15:55 ID:Px/Nyeg6

>>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 pops 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.

This thread has been closed. You cannot post in this thread any longer.