Re: [Pyobjc-dev] Re: Making List<->Array bridging transparent
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2002-11-10 18:01:08
|
On Saturday, Nov 9, 2002, at 18:10 Europe/Amsterdam, bb...@ma... wrote: > So, if we were able to make an encapsulated NSArray inherit from the > base class 'list' on the Python side, it would behave exactly like any > other 'list' in all contexts. Unless the implementation directly accesses the list representation! The implementation of the list type predates newstyle classes (obiously) and does not always check if it is save to directly accesses the representation instead of using accessor functions (the former is more efficient and used to be equivalent). > > There is some subtlety -- for example, the '2' in the above example > really is an 'int' and not a 'FooInt'. To preserve it as a FooInt, I > would need to redefine all of the math operations (__add__, etc) on > FooInt to return instances of FooInt. Of course, I can't do anything > about it [I don't think] if FooInt is the operand -- i.e. in the case > of '1 + x'. 'if FooInt is not the operand' :-) > > Or something like that... I haven't fully wrapped my head around this > stuff yet. Subclassing builtin types works just like subclassing normal objects. > > Ronald: Can you point me to the bug that you filed and a description > of the fix? Is a workaround possible? Bug: http://sourceforge.net/tracker/ ?func=detail&aid=633152&group_id=5470&atid=105470 The bugreport is for a slightly different problem: as noted above the implementation of list sometimes directly accesses the datastructure, even if subclasses have overridden the accessor functions. This is more obviously a bug than the problem you were seeing and the correct fix for this problem also solves our problem :-) I don't think there is a workaround for this. > > As much as I hate to limit our feature set, I feel it is absolutely > critical that PyObjC remain compatible with the Python distributed by > Apple. I agree, PyObjC gets less usefull if it requires you to install a seperate version of Python (especially so if that different version is an unreleased version of Python). Ronald |