The implementation strives to be useful under the majority of reasonable use cases,
to be compact, understandable and sufficiently fast.
There is no pretense of complete generality, nor of absolute efficiency.
In case serialize does not meet exactly your requirements, the code
should be immediate enough to tweak to your needs.