in reply to coding style suggestion: (...)[1] vs. [...]->[1]

From looks, I like the anonymous array one too because brackets are...well, sexy. But for those interested in micro optimization, the benchmarks say that the list is faster.

Benchmark: running anon, list for at least 5 CPU seconds... anon: 6 wallclock secs ( 5.25 usr + 0.01 sys = 5.26 CPU) @ 875 +11.49/s (n=460119) list: 4 wallclock secs ( 5.29 usr + 0.00 sys = 5.29 CPU) @ 121 +428.51/s (n=642243) Rate anon list anon 87511/s -- -28% list 121429/s 39% --

Those are the benchmarks from your script above. Regardless how you vary the length of the string, the ratio held around the same. Hope this helps.

Anonymously yours
Anonymous Nun

Replies are listed 'Best First'.
Re: Re: coding style suggestion
by thens (Scribe) on Sep 19, 2003 at 13:40 UTC
    I understand there is a perfomance penalty with options 2. But for small sized list I guess this is affordable. As you say these brackets stand out from the ()s which may be taken for a precedence paranthesis.

    Anyway, all your suggestions were enlightening.

    -T