From: <bc...@wo...> - 2000-10-19 10:54:17
|
[Samuele] >[Finn] >> >> >sys.path (py) > java pkgs > sys.path (java) maybe is better ? >> >> >if P is py pkg, import P will load the py pkg P independently of >> >classpath... >> >> >One will be still able to access the shadowed java pkg through the py >> >pkg. >> >> >> >> Yes, I think this would be better. >> > >> >Fine, but as I wrote in a succesive mail, JimH put this precedence in place >> >to avoid possible performance penalties >> >by lookup in "applets" case: ... >> >> Jythonc already goes through great pains to detect which of the name >> spaces imported is actually java packages. The list of packages is then >> initialized in Py.initProperties. Could we define that this explicit >> list of identified java packages should be searched before all the >> others? > >Yes but the performance problem is with sys.path(py) not the java pkgs, >for them we already collect static information in PackageManager >also based on the list constructed by jythonc. > >What we need (my opinion): we need an analougous list for the py pkgs: >so given a pkg name -in the import code- we can avoid to lookup for name x.y as >a compiled py pkg/module when it is in fact a java pkg. >We cannot just use the java pkg information because with the new order >py pkg can hide them and we want import to deliver a py pkg if it's the case. Right, I think I understand now. The list of module would then look like: module_list = ['x', 'x.y'] and the code that look for java packages would then look like this: if module_list != None: if modName in module_list: # here modName is not a java package, so there # is no need to try an expensive forName(modName) # across the network. return null // do normal java package load here. >This list can also be a real mapping py pkg -> java class. You've lost me here. Are you saying that the module list should be like this: { 'x' : 'x.__init__', 'x.y' : 'x.y' } ? >This would make thing clearer and enable some interesting but clean >features. For example if your compiled code run not under a sec. mgr >you can change the value of sys.path and load also code from there. regards, finn |