• Kirill Smelkov's avatar
    Add PyDict mode · 3bf6c92d
    Kirill Smelkov authored
    Similarly to StrictUnicode mode (see b28613c2) add new opt-in mode that
    requests to decode Python dicts as ogórek.Dict instead of builtin map.
    As explained in recent patch "Add custom Dict that mirrors Python dict
    behaviour" this is needed to fix decoding issues that can be there due
    to different behaviour of Python dict and builtin Go map:
    
        ---- 8< ----
        Ogórek currently represents unpickled dict via map[any]any, which is
        logical, but also exhibits issues because builtin Go map behaviour is
        different from Python's dict behaviour. For example:
    
        - Python's dict allows tuples to be used in keys, while Go map
          does not (https://github.com/kisielk/og-rek/issues/50),
    
        - Python's dict allows both long and int to be used interchangeable as
          keys, while Go map does not handle *big.Int as key with the same
          semantic (https://github.com/kisielk/og-rek/issues/55)
    
        - Python's dict allows to use numbers interchangeable in keys - all int
          and float, but o...
    3bf6c92d
ogorek.go 35.3 KB