How to convert float to byte array in Godot 3.0

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Maxim
:warning: Old Version Published before Godot 3 was released.

In “Binary serialization API” section of documentation I found, that in File and PacketPeer engine uses simple serialization. Is it possible to call serialization or conversion methods from my GDScript?

For example, I want to get array of 4 bytes from 1 float.
Maybe it can be added to some Pool*Array. Because I did not find any way to write floats to PoolRealArray and get correct converted PoolByteArray from it.

Maybe there exists some other way to convert built in types to byte arrays.

:bust_in_silhouette: Reply From: Zylann

The closest answer I know of is this class StreamPeerBuffer — Godot Engine (latest) documentation in English
It sounds related to network though, so I don’t know if that’s exactly what you need.