title: can msgpack provide better performance and identical functionality of python's struct.pack()?
body: <p>This <a href="https://stackoverflow.com/questions/9884080/fastest-packing-of-data-in-python-and-java">post</a> compares a number of serialization routines and indicates msgpack is faster that Python's <code>struct.pack()</code> and unpack() routines. I'd like to use msgpack but cannot figure out how to use <code>msgpack.packb()</code> for floats or doubles in an equivalent way as <code>struct.pack()</code>.</p>
  
  <p>I need to send N doubles via udp from <strong>python</strong> to a <strong>C/C++</strong> listener that reads N doubles via udp/ip. The C/C++ listener cannot be modified. The Python <code>struct.pack()</code> method works well like this clip for packing N=3 doubles:</p>
  
  <pre><code>import struct
  import msgpack
  
  packer = struct.Struct('ddd')
  myTuple = (1.1, 2.2, 3.3)
  packedData = packer.pack(*myTuple)
  </code></pre>
  
  <p>print(packedData) yields:</p>
  
  <pre><code>b'\x9a\x99\x99\x99\x99\x99\xf1?\x9a\x99\x99\x99\x99\x99\x01@ffffff\n@'
  </code></pre>
  
  <p>Then trying the same thing with msgpack:</p>
  
  <pre><code>msgPackedData = msgpack.packb(myTuple)
  </code></pre>
  
  <p>and print(msgPackedData) yields:</p>
  
  <pre><code>b'\x93\xcb?\xf1\x99\x99\x99\x99\x99\x9a\xcb@\x01\x99\x99\x99\x99\x99\x9a\xcb@\nffffff'
  </code></pre>
  
  <p>The outputs are clearly not the same. Packets sent with struct.pack() are interpreted properly by the udp listener perfectly, but I'd like to gain the performance improvement of msgpack.</p>
  
  <p>Can the performance of msgpack be gained while producing identical output as <code>struct.pack()</code>?</p>