Re: [Pyobjc-dev] pickled Objective-C objects
Brought to you by:
ronaldoussoren
From: Just v. R. <ju...@le...> - 2003-02-23 21:13:46
|
A couple of quick thoughts. Guido and Tim Peters have been doing a lot of work on pickle very recently (for 2.3, it's in 2.3a2). I don't know the details but it has to do with new style classes, so probably affects PyObjC (in a good way, hopefully ;-). The original boolean dump flag denoting text/binary has been upgraded to mean the protocol version: protocol 0 is the text version, 1 is the original binary protocol, 2 is a new binary protocol, which apparently has better (more efficient) support for new style objects. I'm not sure how it all works, but if it would make things easier, I would be happy with a 2.3-only solution. I noticed that unpickling a new style object causes cls.__new__ to be called. This currently does not work for ObjC classes as they insist on being allocated with alloc(). However, ObjC's alloc/init protocol is in many ways equivalent to Python's __new__/__init__ protocol, so as a first step towards supporting pickling, I propose to make __new__ an alias for alloc, and move the "TypeError: Use class methods to instantiate new Objective-C objects" exception to the __init__/tp_init method. Calling an ObjC class will then still result in that exception, while still properly supporting __new__. Just |