Skip to content

Support Decimal-backed Coordinates with string-based serialization #284

Open
@navignaw

Description

@navignaw

Coordinate currently takes a float as input.

Would it be possible to support either a float or Decimal? The main benefit would be using string serialization to preserve precision.

I'm not sure if this applies to pydantic, but in marshmallow docs, there is a warning about using floats:

If a JSON float value is passed to this field for deserialization it will first be cast to its corresponding string value before being deserialized to a decimal.Decimal object. The default str implementation of the built-in Python float type may apply a destructive transformation upon its input data and therefore cannot be relied upon to preserve precision. To avoid this, you can instead pass a JSON string to be deserialized directly.

(If this is not true for pydantic, feel free to close this issue!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions