Changes between Version 60 and Version 61 of pyson


Ignore:
Timestamp:
02/09/22 10:39:46 (3 years ago)
Author:
wouter
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • pyson

    v60 v61  
    6363The dict and list are treated even more special as we also support the List[TYPE] and Dict[KEYTYPE, VALUETYPE] types.
    6464
    65 WARNING: Using Decimal causes rounding errors. This is because pyson takes python's json representation format which contains floats for numbers. And floats can not represent all decimals accurately. For example, in python {{{str(0.24745759773026107) == '0.24745759773026108'}}}. Overall, a number string "N" in your json text will converted as {{{Decimal(str(float("N")))}}} . When in doubt, check for your number "N" that str(float(N))==N, if not you have a rounding issue.
    66 
     65{{{#!td style="background: #fee"
     66Using Decimal may cause rounding errors even before they get to Pyson, because json converts them to float. And floats can not represent all decimals accurately. For example, in python {{{str(0.24745759773026107) == '0.24745759773026108'}}}. Overall, a number string "N" in your json text will converted as {{{Decimal(str(float("N")))}}} . When in doubt, check for your number "N" that str(float(N))==N, if not you have a rounding issue.
     67}}}
    6768You can use {{{ Union[X, NoneType] }}} where {{{NoneType=type(None)}}} or {{{Optional[X]}}}if the object can also be None. So for exmple you can use {{{reservationBid:Union[Bid,type(None)] = None}}}. Do not use the mypy.NoneType which is an entirely different class. We do not support {{{ Union[X,Y] }}} where both X and Y are not NoneType.
    6869