« Return to Thread: Importing packages and startup time in Jytion 2.5
Hi,
I am porting a large mixed Java / Jython desktop application from
Jython 2.2.1 to 2.5. The applications's menu is Jython code.
In version 2.2.1, I could simply import a package:
import pyinventory
and then instantiate at will any class in the package (even with an
empty __init__.py for the package):
pyinventory.inventory_description.InventoryDescription()
where "pyinventory" is a package, "inventory_description" is a module
and "InventoryDescription" is a class. it seems as if Jython 2.2.1
was loading the required class only when they were instantiated.
Importing only the package does not seem to work in Jython 2.5 (the
referenced module is never found). So I changed the imports to import
all the needed modules containing classes that will be instantiated in
the current module:
import pyinventory.inventory_description
...
It nows seems as if Jython will load at once all the application in
memory when the application is started. Once loaded, the application
is a lot faster with Jython 2.5 than it was with version 2.2.1. The
only problem is that the applications's startup time went from 4 ~ 5
seconds to 45 ~ 50 seconds.
The (Jython) menu is loaded from a Java class containing:
static public void main(String args[])
{
... (some initialization code for the application)
try
{ PySystemState.initialize();
PySystemState sys = new PySystemState();
PyStringMap dic = new PyStringMap();
sys.path.append(new PyString("rmn.jar"));
sys.path.append(new PyString("lib/jython.jar"));
sys.path.append(new PyString("lib/rmnjlib.jar"));
sys.path.append(new PyString("lib/jy25lib.jar/Lib"));
sys.path.append(new PyString("lib/forms-1.2.1.jar"));
sys.path.append(new PyString("lib/swingx-0.9.5.jar"));
sys.path.append(new PyString("lib/reportlab-2.3.jar"));
sys.path.append(new PyString("lib/jfreechart-1.0.13.jar"));
sys.path.append(new PyString("lib/iText-2.1.5.jar"));
sys.path.append(new PyString("macros"));
interp = new PythonInterpreter(dic, sys);
interp.exec("import main");
}
catch (PyException ex4)
{ System.err.println(ex4);
}
}
The tests were made on Windows XP, using Java 6.0.
1) Am I doing something wrong?
2) Is there anything (a configuration switch?) that will force Jython
to lazily import the modules when instantiated?
Thanks.
Marcel
------------------------------------------------------------------------------
_______________________________________________
Jython-users mailing list
Jython-users@...
https://lists.sourceforge.net/lists/listinfo/jython-users
« Return to Thread: Importing packages and startup time in Jytion 2.5
| Free embeddable forum powered by Nabble | Forum Help |