Re: Instantiation of class objects

From: Date: Fri, 22 Dec 2000 00:23:40 +0000
Subject: Re: Instantiation of class objects
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-42099@lists.php.net to get a copy of this message
On Thursday 21 December 2000 14:58, Ignacio Vazquez-Abrams wrote: > It can't tell if the object(s) you're instantiating are going to be used > the same way, or for the same thing, or what, and AFAIK there's no surefire > way of reinitializing old objects, so there's no point in caching them. It has to have SOME kind of run-time knowledge. If you say "new foo()" and then later (in another script) say "new foo()" I would think that the object would have been cached from the other script and could be reused. Perhaps re-calling the constructor, or making a call into "foo()->init()" if it exists. The test objects we're using are small...tiny in fact. They have 3 member variables, 1 method, a constructor which calls the parent constructor and that's it. Since it's only 1 parent and 1 child (not nested deeply) it shouldn't give THAT much overhead. I would love to see the Zend engine implement some kind of caching and a callback/hard call into the method to reinit it. (Maybe re-call the constructor method explicitly?) One of the main ideas of objects (obviously) is reuse. What good is reuse if you take a huge performance hit? You gain maintainability but lose such a huge performance benefit that it (at least for us) is going to cause us to NOT use objects - even as much as we'd love to. > Are you sure that it's new that's slowing it down, and not in fact just OO > overhead? Try using new for the heck of it in the procedural version, then > use the procedures instead. OOP does have overhead, so it may not be new on > its own. We can give it a shot, but the PHP implementation of the vtable on the OO stuff shouldn't have too much overhead. Whether that method's called via an object's vtable or the global space shouldn't make a whole lot of difference unless something's slow about the resolution of that method call against the object model. Off to test... -Szii

« previous php.dev (#42099) next »