Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Anti-inside-out-object-ism

by xdg (Monsignor)
on Dec 09, 2005 at 21:51 UTC ( [id://515662]=note: print w/replies, xml ) Need Help??


in reply to Anti-inside-out-object-ism

Another common concern raised is about speed.

There is overhead associated with DESTROY that doesn't exist (in quite the same way) for hash-based objects where garbage collection is left to Perl rather than done by hand. If lots of objects are being generated and destroyed, this may be an issue for some individuals.

Also, depending on the implementation, inside-out accessors can be much slower than hash-based accessors, but the difference can be very small if the inside-out class caches the refaddr, as this node demonstrates. (The array-based implementation of Object::InsideOut is faster yet, I believe, but that isn't an apples-to-apples comparison.)

As a side note, the tendency of inside-out classes to be implemented with attributes for syntactic sugar is another potential downside. (Incompatibility with other Attribute::Handlers modules, for example.) But that relates to implementation choices, not the inside-out paradigm itself.

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Replies are listed 'Best First'.
Re^2: Anti-inside-out-object-ism
by adrianh (Chancellor) on Dec 10, 2005 at 21:43 UTC
    There is overhead associated with DESTROY that doesn't exist (in quite the same way) for hash-based objects where garbage collection is left to Perl rather than done by hand. If lots of objects are being generated and destroyed, this may be an issue for some individuals.

    Although when I've benchmarked inside-out vs hash based versions of objects in real world scenarios the overhead of the extra DESTROY just disappears in the noise.

    I suspect it's going to be a rare environment where one extra method call perl object makes a significant difference.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-18 19:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found