I highly suggest using Google Protocol Buffers as implemented in Python as protobuf for this as it will handle the serialization on both ends of the line. It has Python bindings that will allow you to easily use it with your existing Python program.
I highly suggest using Google Protocol Buffers as implemented in Python as protobuf for this as it will handle the serialization on both ends of the line. It has Python bindings that will allow you to easily use it with your existing Python program. Using your example code you would create a .
Proto file like so: message SomeCoolMessage { required string key = 1; required double value = 2; } Then after generating, you can use it like so: randKey = random. Choice( nodeList.keys() ) data = SomeCoolMessage() data. Key = randKey data.
Value = nodeListrandKey mySocket. Sendto ( data. SerializeToString() , address ).
I was just about to write up a suggestion for Protocol Buffers myself! – Jarrod Roberson Oct 31 at 20:02 Yeah I really like it; makes serializing things like this a breeze. – smoak Oct 31 at 20:04.
I'd probably use the json module serialize the data.
You need to serialize the data. Pickle does this built in for you, and you can ask pickle for an ascii representation of the data vs binary data (see the docs), or you could use json (it also serializes the data for you) both are in the standard library. But really there are a hundred thousand different libraries that handle ALL the work for you, in getting data from 1 machine to another.
I'd suggest using a library. Depending on speed, etc. There are different trade offs for the various libraries.In the standard library you get HTTP, that's about it (well and raw sockets). But there are others.
If super fast speed is more important than other things..., zeroMQ, or google's protocol buffers might be valid options. For me, I use rpyc usually, it lets me be totally lazy, and just call over to the other process across the network. It's fast enough usually.
You know that UDP has no guarantee that the data will ever show up on the other side, or that it will show up IN ORDER. For your application you may not care, I don't know, but just thought I'd bring it up.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.