[Pyobjc-dev] Re: [Pythonmac-SIG] pyobjc / cocoa

Jack Jansen Jack.Jansen@cwi.nl
Fri, 18 Oct 2002 11:15:34 +0200


On Thursday, October 17, 2002, at 10:42 , Bill Bumgarner wrote:
>> The current mechanism is a bit of a hack: the 'objc' module maintains 
>> a list of methods that are added if a selector is present in the 
>> objective-C class (e.g. if the class has 'objectForKey:' add an 
>> __getitem__ method that calls objectForKey_). This should work for 
>> most collection classes.
>
> This is actually a really good solution in that it greatly automates 
> the bridging process and should work transparently with the 'no cost' 
> bridged CFTypes.
>
> Anything that makes a copy of data as it is passed across the bridge 
> should generally be avoided -- strings are about the only exception.

Now that I think about it: why should strings be an exception? Could we 
not create an NSString subclass (along the same lines as your ideas on 
dictionaries and lists) that will wrap either a Python string or a 
Python unicode object? Actually, two wrappers (one for strings, one for 
unicode) may be easier, there's a lot of code that's going to be 
different depending on whether the underlying object is a string or 
unicode.
Hmm, actually we may want a whole family of wrappers so we can use 
Python strings to represent the whole string/data/url group.
--
- Jack Jansen        <Jack.Jansen@oratrix.com>        
http://www.cwi.nl/~jack -
- If I can't dance I don't want to be part of your revolution -- Emma 
Goldman -