Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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

by Fletch (Chancellor)
on Feb 03, 2004 at 18:16 UTC ( #326276=categorized answer: print w/replies, xml ) Need Help??

Q&A > object-oriented programming > Why are objects slower than procedural subs/data structs? - Answer 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.

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 making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2016-08-30 20:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The best thing I ever won in a lottery was:















    Results (423 votes). Check out past polls.