Custom Objects and Classes for Scripting 2005-03-27 - By kim aldis
Back
> -- --Original Message-- -- > From: owner-xsi@(protected) > [mailto:owner-xsi@(protected)] On Behalf Of Brad Friedman > Sent: 26 March 2005 21:35 > To: XSI@(protected) > Subject: Re: Custom Objects and Classes for Scripting > > > > What I'm currious about is just overhead and best practices > with that technique. The CGSoup piece isn't an all inclusive > tutorial that covers all the potential pitfalls so i was > hoping someone had been using the technique and could shed > some light on the intricacies of it. In particular, if > anyone had been using it as a function library. Since its > functions on an instance rather than static functions in a class... > how does one get around the overhead of constant > instantiation of the object by clients of the library? Or is > the overhead so tiny that its trivial to constantly > instantiate the object to get at what are essentially static methods? > I use this method for pretty much all my libtary code now. My observation the overhead of instanciation is negligable when compared to calling the command itself, which is pretty slow. Although Brad is the one to answer questions on speed. In fact, one of the great advantages of this method is that you can minimise the number of calls to commands by creating them as methods of an object itself, creating the object, for example, outside of the loop, keeping the method calls inside.
If you're really concerned, though, why not do some timing tests.
As for Python classes as commands, I also use this a lot to pull in the kind of tools not available from Jscript or VB. In particular I prefer the file handling tools but there's also socket handling, mail, filetype, XML, SQL ...... It opens up a whole bunch of possibilities. It allows me to carry on working with my core scripting tools, which are Jscript, but with increased fucntionality.
An yeah, I know Bernard. I'll get on the case as soon as I clear up what I'm doing right now. I should keep my mouth shut until I can deliver. ;)
--- Unsubscribe? Mail Majordomo@(protected) with the following text in body: unsubscribe xsi
|
|