Issue2480

classification
Title: Repeating from import results in reload
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.7
Milestone: Jython 2.7.1
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: darjus Nosy List: darjus, tcoker, zyasoft
Priority: Keywords:

Created on 2016-02-26.20:21:54 by tcoker, last changed 2016-03-14.16:41:48 by zyasoft.

Messages
msg10794 (view) Author: Tom Coker (tcoker) Date: 2016-02-26.20:21:53
a)  for i in range(100000):
        from org.python import Version

b)  for i in range(100000):
        import org.python.Verion as Version

a) is massively slower than b).

Looks like the problem is the below from imp.java which makes it attempt to load the nonexistent org.python.__path__ because __path__ is never set on the java package object.

    private static void ensureFromList(PyObject mod, PyObject fromlist, String name,
                                       boolean recursive) {
            if (mod.__findattr__("__path__") == null) {
                return;
            }

Stack trace showing the class load:

	at org.python.core.Py.loadAndInitClass(Py.java:991)
	at org.python.core.Py.findClassInternal(Py.java:926)
	at org.python.core.Py.findClassEx(Py.java:977)
	at org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:133)
	at org.python.core.packagecache.PackageManager.findClass(PackageManager.java:33)
	at org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:122)
	at org.python.core.PyJavaPackage.__findattr_ex__(PyJavaPackage.java:134)
	at org.python.core.PyObject.__findattr__(PyObject.java:946)
	at org.python.core.imp.ensureFromList(imp.java:997)
	at org.python.core.imp.ensureFromList(imp.java:992)
	at org.python.core.imp.import_module_level(imp.java:986)
	at org.python.core.imp.importName(imp.java:1062)
	at org.python.core.ImportFunction.__call__(__builtin__.java:1280)
	at org.python.core.PyObject.__call__(PyObject.java:431)
	at org.python.core.__builtin__.__import__(__builtin__.java:1232)
	at org.python.core.imp.importFromAs(imp.java:1156)
	at org.python.core.imp.importFrom(imp.java:1132)
msg10801 (view) Author: Darjus Loktevic (darjus) Date: 2016-03-07.00:59:52
Just taking out that check seems to fix the issue and regrtest is still passing :-/
msg10802 (view) Author: Darjus Loktevic (darjus) Date: 2016-03-07.03:14:45
Should be fixed in: https://github.com/jythontools/jython/commit/8c2c1c287e22bc2c907b4bf5d9e98bc911db112b
History
Date User Action Args
2016-03-14 16:41:48zyasoftsetstatus: pending -> closed
2016-03-07 03:15:03darjussetassignee: darjus
2016-03-07 03:14:56darjussetstatus: open -> pending
resolution: accepted
2016-03-07 03:14:46darjussetmessages: + msg10802
2016-03-07 00:59:53darjussetnosy: + darjus
messages: + msg10801
milestone: Jython 2.7.2 -> Jython 2.7.1
2016-03-04 00:17:30zyasoftsetmilestone: Jython 2.7.2
2016-02-27 03:12:03zyasoftsetnosy: + zyasoft
2016-02-26 20:21:54tcokercreate