title: python lightweight solution for typecasting float(64) to bytes
body: <p>I'd like to have a very simple solution in displaying the raw bytes for a float value (or more consecutive ones in memory). in my understanding, this is named typecasting (reading the memory values in byte) not to be misunderstood as casting (reading the value and interpreting that in byte).</p>
  
  <p>The simplest test seem to be:</p>
  
  <pre><code>import numpy
  a=3.14159265
  print(a.hex())
  # Returns 0x1.921fb53c8d4f1p+1
  b=numpy.array(a)
  print(b.tobytes())
  # returns b'\xf1\xd4\xc8S\xfb!\t@'
  # expected is something like 'F1' 'D4' 'C8' '53' 'FB' '21' '09' '40'
  </code></pre>
  
  <p>but the method hex() returns an Interpretation of the IEEE FLOAT represantation in hex. The second method shows four hex-Byte markers <code>\x</code> but I wonder as a float64 should read 8 Bytes. Further I'm wondering by the other characters.<br>
  I good old simple C I would have implemented that by simply using an unsigned int pointer on the memory address of the float and printing 8 values from that unsigned int "Array" (pointer.)<br>
  I know, that I can use C within python - but are there other simple solutions?<br>
  Maybe as it is of interest: I need that functionalaty to save many big float vectors to a BLOB into a database.</p>
  
  <p>I think, similiar Problems are to be found in <a href="https://stackoverflow.com/questions/38874139/correct-interpretation-of-hex-byte-convert-it-to-float">Correct interpretation of hex byte, convert it to float</a> reading that if possible (displayable characters) they are not printed in <code>\x</code>-form. How can I change that?</p>