Currently, when we do "import theano", cutils_ext is compiled if it doesn't exist already. This is done in the "import cutils" statements.
I would like to delay this import until we actually show some intent to use it... at first sight it would only be in ProfileMode.__setstate__ and CLinker._execute.
The motivation is to be able to get a compiled cutils_ext module from some place else and copy it into Theano's compiledir: the problem is I need to import theano to obtain theano.config.compiledir, and thus it's already too late... (it's on a computer where the compilation does not work).
Can anyone foresee issues with such a change? The main drawbacks I can see are:
1. Just doing "import theano" would not let us do a quick check to make sure compilation seems to work ok, we would have to manually import cutils
2. It is against the general guideline "imports should come at the top of the file"
3. The extra import statements in ProfileMode.__setstate__ and CLinker._execute might slow things down. Anyone knows how costly it is when one tries to re-import an already imported module? (I know it has no effect, but I don't know if it's slow). Alternatively, the code could be a bit smarter and just do a boolean comparison with a module-wide flag that would be set after the first import, to avoid further import attempts.
Thoughts?
-=- Olivier