Floating precision encoding - large file

Iā€™m using Scatter with ndarray.dtype float32. The output file size is not optimal: ā€œyā€: [7.3670160000000005, 7.333488000000001, 7.330439999999999,ā€¦

Are there Plotly JSONification options to avoid creating enormous files when it is not necessary?

Please find element of my own answer in case someone else in the community is interested:

def float2str(obj):
    """Float to string."""
    return [format(x, '.5g') for x in obj]


class CustomPlotlyJSONEncoder(PlotlyJSONEncoder):
    """Customized PlotlyJSONEncoder encoder."""

    def default(self, obj):
        """The new custom default encoder."""
        if is_float_dtype(obj):
            return float2str(obj)

        return PlotlyJSONEncoder.default(self, obj)

    sep = (",", ":")
    data_js = dumps(data, cls=CustomPlotlyJSONEncoder, separators=sep)