Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^7: Declaring with my, assigning, and testing in same line (attributes)

by choroba (Cardinal)
on Dec 15, 2015 at 09:44 UTC ( [id://1150350]=note: print w/replies, xml ) Need Help??


in reply to Re^6: Declaring with my, assigning, and testing in same line (attributes)
in thread Declaring with my, assigning, and testing in same line

this behaviour means that the untie happens almost immediately after the tie, i.e. the potential for possible ugly side effects is practically zero.
My benchmarks show attributes are much slower than a (&;@) sub, especially for short lists (many thousand times).
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^8: Declaring with my, assigning, and testing in same line (attributes)
by LanX (Saint) on Dec 15, 2015 at 10:23 UTC
    > are much slower

    Did you expect otherwise? :)

    That's normally the prize for syntactic sugar...

    I wouldn't be surprised if Attribute::Handlers is to be blamed for a big part of the delay.

    Using attributes directly might speed up things, but it will still be considerably slower.

    But when used in the context of debugging or similar speed wouldn't matter that much.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1150350]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-19 01:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found