py_yyjson icon indicating copy to clipboard operation
py_yyjson copied to clipboard

Change behavior for ReaderFlags.BIGNUM_AS_RAW and ReaderFlags.NUMBERS_AS_RAW

Open MichaelSquires opened this issue 8 months ago • 1 comments

This PR makes the following changes:

  • Change behavior of ReaderFlags.BIGNUM_AS_RAW:
    • Old behavior: Return big numbers (>= 2**64, < -2**63) as Decimals.
    • New behavior: Return big numbers (>= 2**64, < -2**63) as python long integers.
  • Change behavior of ReaderFlags.NUMBERS_AS_RAW:
    • Old behavior: Return all numbers as Decimals.
    • New behavior: Return all numbers as python long integers.
  • Added tests to validate behavior of serializing/deserializing numbers with various flags.

Note: These changes are not backward compatible and will probably require a major version bump.

MichaelSquires avatar Apr 21 '25 21:04 MichaelSquires

Hi, I realize this is a potentially controversial change and I'm glad to discuss it. Basically, we needed to be able to deserialize large integers without the Decimal() wrapper. This seemed like a good place/way to split it. Hopefully you agree :)

MichaelSquires avatar Apr 21 '25 21:04 MichaelSquires