Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Answer: Why are objects slower than procedural subs/data structs?

( #326276=categorized answer: print w/ replies, xml ) Need Help??

Q&A > object-oriented programming > Why are objects slower than procedural subs/data structs? contributed by Fletch

Method dispatch overhead. When you say foo( $a ) whatever foo in the current scope is called dirrectly. When you say $obj->bar( $b ), then perl has to check what $obj is (a scalar holding a blessed ref? a class name), then try and call Whatever::bar, and if that doesn't work try SuperWhatever::bar . . .

Granted there's some caching done, but it's more than just a simple subroutine call.

Comment on Answer: Why are objects slower than procedural subs/data structs?
Select or Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (13)
As of 2014-11-26 20:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (172 votes), past polls