I have recently started to use Python's xdrlib module. I was surprised to see that Packer
and Unpacker
are classes that you need to instanciate and contains method like reset
and get_buffer
. Calls to Packer
and Unpacker
instance methods accumulate data in the buffer until you use it. The standard usage seems to be that you create one Packer and one Unpacker instance per Client, but this is not thread safe/
I said I was surprise because I was expecting to have just functions to pack the data into bytes and then write things like:
mybuffer += pack_int(3)
or having a Message class (a buffer with methods like append_int
) and disposing the Message instance after usage.
The current design seems to put persistency in the wrong place. Is it really like this or there is some important feature that I am missing? What is the rationale of this design?