Re: [Pyobjc-dev] PythonBrowser example/study + bug report
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2002-12-05 06:52:01
|
On Wednesday, Dec 4, 2002, at 22:57 Europe/Amsterdam, Just van Rossum wrote: > 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. Calling back to Python would be no problem, I already use a callback to python for adding __getitem__ et. al. to classes. Converting exceptions is also not performance critical. > >>> 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. Interesting. > >> >> 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 know, that's why I didn't check in my changes just yet. We must get significantly faster if PyObjC is to be used in command-line utilities (the performance of Examples/addressbook.py is way too slow to be really usable) > > 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? The proxy building code is all in Objective-C (and mostly this is just plain C code). ObjCClass_New in Modules/objc/objc-class.m builds proxy classes. This function is used by ObjC_GetClassList in Modules/objc/class-list.m when building the list of all classes known to the implementation. Ronald |