Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
P is for Practical
 
PerlMonks  

Why are objects slower than procedural subs/data structs?

by Sol-Invictus (Scribe)
on Feb 03, 2004 at 12:50 UTC ( [id://326269]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

Sol-Invictus has asked for the wisdom of the Perl Monks concerning the following question: (object-oriented programming)

what is it that makes objects 20-50% more expensive to use?

Originally posted as a Categorized Question.

  • Comment on Why are objects slower than procedural subs/data structs?

Replies are listed 'Best First'.
Re: Why are objects slower than procedural subs/data structs?
by Fletch (Bishop) on Feb 03, 2004 at 13:16 UTC

    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.

Re: Why are objects slower than procedural subs/data structs?
by pajout (Curate) on Nov 08, 2005 at 07:38 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://326269]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.