in reply to Re^2: Does @{ } copy arrays?
in thread Does @{ } copy arrays?

less efficient in perl 5.10.0 onwards (attaching of PERL_MAGIC_arylen magic to the AV).

Is that going to revert?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP PCW It is as I've been saying!(Audio until 20090817)

Replies are listed 'Best First'.
Re^4: Does @{ } copy arrays?
by dave_the_m (Monsignor) on Oct 17, 2009 at 10:50 UTC
    Is that going to revert?
    No. It's a trade off that made $#a slightly slower and bigger while making arrays smaller and faster (as long as you don't access them via the $# mechanism).

    Dave.

      Thank you for your response.

      arrays smaller and faster (as long as you don't access them via the $#

      That's unfortunate.

      Is it really impossible to make read-only references to $#.. equivalent (in performance, cost and side-effects), to ( Scalar @.. - 1 )?

      Ie. Could not the application of magic to an array, and all the penalties that go with it, be deferred until it is used in an lvalue context?


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Ie. Could not the application of magic to an array, and all the penalties that go with it, be deferred until it is used in an lvalue context?

        ehm, that sounds like a very risky approach for tuning an edge case:

        DB<7> sub tst { $_[0]=3 } DB<8> @a=(1..10) DB<9> tst $#a DB<10> p @a 1234

        personally I wouldn't care too much about the performance penalty, but the possible side-effects after forgetting that $#a is an lvalue and $_[0] is an alias, should be a reason enough to stick with scalar @a.

        Cheers Rolf