On Sun, Mar 09, 2003 at 03:46:39PM -0500, Dan Sugalski wrote: > Presenting internal state in a rational form is a rather > significantly different thing than being able to serialize things, > and I don't think it's feasable, unfortunately. It'll require too > much consistency to be useful (as I don't think you'll get that > consistency) and you'll likely end up just dropping back and > grovelling over the internal nasty bits anyway. > > Serialization is a specific and very useful application, and one that > we need in general (otherwise we won't be able to have constant PMCs) > so it'll be there, but being able to expect to walk a pool of > heterogenous objects from a variety of different object systems is > more than I think you're likely to get. > > More to the point, it's a level of complexity I'm unwilling to commit > to, because it's not needed for our required functionality, useful > though it might be. (Even in the limited circumstances it's likely to > be available in)
Forgive me for jumping into the conversation late, but I'm not really sure where this complexity is coming from. I've worked quite a bit with serialization mechanisms in Python and other languages, but maybe I'm missing something. In Python, we just have a method named __getstate__ that must return one of the basic types: dict (hash), list (vector), None, int, string. The marshaller must know how to write these things to a file, send them across a socket via some protocol, or whatever. The dicts and lists can contain other objects, of course, and those will be queried for their state, and so on. This isn't really that hard to implement, IME, and it's never been an issue to put the state of an object into these datastructures. If a method doesn't have a __getstate__, we just grab its attribute __dict__. This bit is obviously not friendly to other languages, but it's also unneccessary - Each language can implement a default `get_state'-type method on its root object PMC that can either return something useful or crash out (Python's would check for self.__getstate__, and if not found, return self.__dict__). Unserializing basically instantiates an object without initializing it and calls __setstate__(data) on it where `data' is what was previously returned from its __getstate__ call. I'm not on a crusade to get a cross-language serialization mechanism, but it would be very convenient and it doesn't seem it would require that much hassle. -- Twisted | Christopher Armstrong: International Man of Twistery Radix | Release Manager, Twisted Project ---------+ http://twistedmatrix.com/users/radix.twistd/