Re: [Pyobjc-dev] Namespaces, intended behavior?
Brought to you by:
ronaldoussoren
From: Ronald O. <ron...@ma...> - 2018-04-05 18:16:52
|
That is correct. There is another reason for that: the lazy loader I mentioned. Apple’s frameworks expose a lot of names and * imports force PyObjC to create Python versions of all of them which uses memory and more importantly takes significant time. Ronald -- On the road, hence brief. Op 5 apr. 2018 om 18:43 heeft Just van Rossum <jus...@gm...> het volgende geschreven: > >> On 05 Apr 2018, at 18:12, Ronald Oussoren <ron...@ma...> wrote: >> >> >> >>> On 5 Apr 2018, at 17:39, Just van Rossum <jus...@gm...> wrote: >>> >>> Hi, >>> >>> I am wondering, is the following intended behavior? >>> >>> ------------- >>> import Foundation >>> >>> class TestMyCustomObject(Foundation.NSObject): >>> pass >>> >>> import AppKit >>> # it's suddenly available via AppKit: >>> print(AppKit.TestMyCustomObject) >>> # even via import *: >>> from AppKit import * >>> print(TestMyCustomObject) >>> ------------- >>> >>> Thanks, >> >> That is expected behavior and is a side effect of lazy loading of frameworks. >> >> In the past I have attempted to expose only the classes that belong in a framework (by exposing only those classes located in the correct framework bundle), but that code turned out to be too slow (because the Cocoa method I used for that is slow), so that got dropped a long time ago. When I started on the lazy loader I didn’t even try to make it guess whether or not a class should be loadable through the current framework wrapper. This is not ideal, but good enough. > > Thanks for the clarification. That does mean that one should pretty much never ever do > > from SomeFramework import * > > Despite the fact that most frameworks have decent prefixes for their sybols. > > Just > |