2 ms·
You can do the same with python's msgpack as the C# version Try this: packer = msgpack.Packer() serialized = packer.pack('stuff you wanna pack')
by chewxy 14y ago
You can do the same with python's msgpack as the C# version
Try this:
packer = msgpack.Packer()
serialized = packer.pack('stuff you wanna pack')
unpacker = msgpack.Unpacker()
unpacker.feed(serialized)
print unpacker.unpack()
I had originally used this, but then as my API scope extended to more than just using msgpack, having a common API interface for json (i.e. the .loads() and .dumps() method) was found to be more useful.
And while I agree with most of the article, I don't think writing more classes is a one-size-fits-all solution. Classes IMO, only makes sense from a heavily OOP point of view.
- niggler 14y agoI dont think the OP was pointing to OOP when talking about classes. You can have classes without a meaningful class hierarchy that still conforms to the OP's desired programming style using protocols like the iterator protocol. A better way to phrase the OP's salient point while sidestepping the polemic of OOP is "Standardize and use protocols".
- the_mitsuhiko 14y ago> You can do the same with python's msgpack as the C# version You can't. The unpacker in msgpack for Python only reads full objects. The C# version lets me go into and out of streaming at will and even skip past objects without reading them into memory. The only thing the Python version of msgpack can do with the unpacker is buffering up bytes internally until an object is ready. That object however could still expand into a 10GB blob of data which I would then have to postprocess.