I suppose when a cast is involved it goes via the external format as well, right?
A cast between two types is going to accept a concrete instance of the input type, in memory, as its argument and then produces a concrete instance of the output type, in memory, as output. If the input data is serialized the constructor for the input type will handle deserialization.