[wp-hackers] Micro optimization - is_a() vs instanceof

Otto otto at ottodestruct.com
Fri Jan 4 17:32:22 UTC 2013

On Fri, Jan 4, 2013 at 9:32 AM, Dobri <dyordan1 at ramapo.edu> wrote:
> What's your source? Did you read this somewhere? If so, do you have a link, it'd be an interesting read… In either case though, my guts say execution time of both is almost negligible, so twice as negligible isn't really doing much, given how much effort it would take to replace it throughout the code (even with regexp or whatnot, which would be quick but prone to introducing bugs). Still, if you have an article that says otherwise, please do link to it. Cheers!

I don't remember where I read this, but instanceof is definitely going
to be faster because it's a language construct, while is_a() is a
function call which involves the overhead of function setup and tear

The difference is probably negliable, but it adds up over time. It
would make sense to switch to instanceof anywhere that it is possible
to do so, however I don't think it is a pressing concern. One of those
fix-it-if-you-spot-it things.


More information about the wp-hackers mailing list