title: Converting python float to bytes
body: <p>I want to convert a Python float into a byte array, encoding it as a 32 bit little-endian IEEE floating point number, in order to write it to a binary file.</p>
  
  <p>What is the modern Pythonic way to do that in Python 3? For ints I can do <code>my_int.to_bytes(4,'little')</code>, but there is no <code>to_bytes</code> method for floats.</p>
  
  <p>It's even better if I can do this in one shot for every float in a numpy array (with dtype numpy.float32). But note that I need to get it as a byte array, not just write the array to a file immediately.</p>
  
  <p>There are some similar-sounding questions, but they seem mostly to be about getting the hex digits, not writing to a binary file.</p>