Coyote's Guide to IDL Programming

IDL Objects are Slow to Initialize

QUESTION: I've created a number of IDL objects, but they seem very slow to initialize. Are they really this slow, or am I doing something wrong?

ANSWER: Creating an object is not slow in and of itself. But if you are not careful about what you are doing, object initiialization and cleanup can be slow. Here is how that might happen.

Suppose you create an object of object class JUNK that doesn't have an INIT method associated with it. (Or a CLEANUP method, for that matter.) When you create the object, IDL will always look for these two lifecycle methods. Failing to find any associated with this object class, it will look for similarly named methods in superclass objects (i.e., those objects this object class has inherited). Failing to find one in any of the superclass objects, IDL begins to look for the appropriate file (e.g., junk__init.pro) in the IDL path.

It is this search that can appear to slow object initialization down significantly. Depending upon how many subdirectories and files you have in the path, IDL can spend a lot of time (secounds) searching for the lifecycle method.

Thus, it is a good idea to define INIT and CLEANUP methods for every IDL object that doesn't inherit these methods from superclass objects. This is true even if you don't do anything in these two methods. For example, they could be as simple as this:

   FUNCTION JUNK::INIT
   RETURN, 1
   END

   PRO JUNK::CLEANUP
   END

<
Google
 
Web Coyote's Guide to IDL Programming