It depends. If it is combined with elemnts removal, epsecially like:
a = a[1..]; a += ({ some_value });
This is quite slow, especially for big arrays :)
No it's not, proof below: (I optimized the range operator in Pike 7.3.11 or so)
---------------------arraybench.pike------------------------ #!/usr/bin/env pike
int main() { for(array(int) a=({19});sizeof(a) < 10000000; a+=a) { int iter; int t=time(); for(float x=time(t) + 1.0;time(t) < x;iter++) { a+=({17}); a=a[1..]; } write("%8d: %12d (%12d)\n",sizeof(a),iter,iter/sizeof(a)); } } --------------------------------------------------------------- Results: 1: 409885 ( 409885) 2: 400459 ( 200229) 4: 380187 ( 95046) 8: 377355 ( 47169) 16: 335558 ( 20972) 32: 707770 ( 22117) 64: 707568 ( 11055) 128: 724203 ( 5657) 256: 724851 ( 2831) 512: 722408 ( 1410) 1024: 731361 ( 714) 2048: 722853 ( 352) 4096: 724260 ( 176) 8192: 718247 ( 87) 16384: 703705 ( 42) 32768: 685720 ( 20) 65536: 685558 ( 10) 131072: 681559 ( 5) 262144: 684715 ( 2) 524288: 677111 ( 1) 1048576: 663094 ( 0) 2097152: 624890 ( 0) 4194304: 600015 ( 0) 8388608: 461745 ( 0)
/ Fredrik (Naranek) Hubinette (Real Build Master)
Previous text:
2003-01-29 01:31: Subject: Re: reasons why pike is better than python?
On Wed, Jan 29, 2003 at 12:55:03AM +0100, Martin Nilsson (Åskblod) @ Pike (-) developers forum wrote:
No, appending elements to arrays are fast in 7.4.
It depends. If it is combined with elemnts removal, epsecially like:
a = a[1..]; a += ({ some_value });
This is quite slow, especially for big arrays :)
No, Pike regexps are faster than e.g. python regexps according to the langauge shootout.
As Martin said already - then Python regexps are slow too. And everyone knows alternative which is faster and powerful, but it is still not in Pike :)
PS: 2 Martin: could you please change the subject to something like: "Reasons why apples are better than oranges?" :)) I think that every language has its advantages and disavantages, which are dependent on task, so... :))
Regards, /Al
/ Brevbäraren