Re: [Pyobjc-dev] PythonBrowser example/study + bug report
Brought to you by:
ronaldoussoren
From: Just v. R. <ju...@le...> - 2002-12-04 21:57:54
|
Ronald Oussoren wrote: > > It can't include a proper traceback? (Sorry if this is naive, I > > know nothing about exceptions in ObjC yet.) > > That's another possibility, is there a function to translate a > traceback to a string (PyErr_Print writes to a file)? Hm, I can't find anything in C. If you can call back to Python, you can use the traceback module. If you want I can try to write a C function that calls traceback.py. > > On the other hand: wouldn't subclassing the module class also be an > > opportunity to speedup loading of Foundation and AppKit by doing > > things lazily? Oh, I don't think we need to subclass module at all: > > we can just inject an arbitrary object into sys.modules; I just > > tried it, and even "from FakeModule import *" works just fine. > > But wouldn't 'from AppKit import *' stop working if the AppKit 'module' > creates the proxies lazily? Not if the object has an __all__ attribute (I played around with this the other day: for star-imports to work the object must either have an __all__ attribute or a __dict__ atribute. I'm pretty sure __all__ is checked first. > I've done some experiments to find why > importing AppKit is as slow as it is. Actually loading the framework > isn't that expensive, the problem is really in creating all proxy > classes and specifically in walking the method-tables of Objective-C > classes. I'll check if I can somehow postpone this until it is really > needed (someone doing dir(NSObject) or creating an instance of the > proxy [or one of its subclasses]). > > My local tree is already somewhat faster by somewhat optimizing > existing code and moving the actual loading code to Objective-C. "Somewhat" isn't quite enough I think... It would be nice if small apps could start up quickly. I think it's worthwhile to play with a fake module object implementing a __getattr__ hook. How much of this proxy-building code is written in Python, if any? If it's in (Obj)C, can you point me to the code so I can try to understand it? Just |