You're not really appending a mapping though; you're inserting a value. What's the benchmark time for doing v+=([ x:y ])?
Seems to be approximately three times slower than v[x] = y. Don't be surprised if that changes due to optimiser additions though - naïve code like this is a typical example of where the optimiser can help turn slow code into quicker code.
/ Johan Sundström (a hugging punishment!)
Previous text:
2003-01-29 09:18: Subject: Re: reasons why pike is better than python?
In the last episode (Jan 29), Mirar @ Pike developers forum said:
a = a[1..]; a += ({ some_value });
^^^^^^^^^^
*removing* elements isn't fast. Adding elements are.
But anyway, I wrote a benchmark for it. It uses v+=({17}) and v[x]=y respectively, up to 100000 elements (k times):
test total user mem (runs) Append array............... 0.808s 0.525s 3540kb (19) (952859/s) Append mapping............. 0.703s 0.459s 3784kb (22) (1090188/s) Append multiset............ 1.132s 0.806s 3684kb (14) (620018/s)
You're not really appending a mapping though; you're inserting a value. What's the benchmark time for doing v+=([ x:y ]) ? It's too bad there isn't an "append array element" syntax that doesn't require you to generate a 1-element array to append.
-- Dan Nelson dnelson@allantgroup.com
/ Brevbäraren