Basic Serialization - a design decision question
steve at holdenweb.com
Fri Apr 6 15:50:17 EDT 2007
> I am a relative newcomer to Python, and I am studying it to understand
> its design. It intrigues me.
> I recently studied Serialization of classes via the pickle/cPickle
> library, and I have a question.
> Why is Serialization handled by a separate library (ie, pickle). Is it
> possible, by design, to have serialization "internally" implemented via
> an implicit ___serialize___ method? Ofcourse, you have to make this
> method not overrideable (sp?). For example, the __repr__ method gives us
> the string representation of a class... similarly, the __serialize__
> method would give us the "serial norm" representation of the class.
> This would allow me to do something like this,
> conn.send(serial(myClass)); // or something like that?
It would be quite possible to do this - it just hasn't been done, is
all. I'm not quite sure what advantage you see for serial(myClass) over
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Recent Ramblings http://holdenweb.blogspot.com
More information about the Python-list