Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dicts should retain insertion order (add spec tests) #1021

Closed
andychu opened this issue Nov 26, 2021 · 4 comments
Closed

Dicts should retain insertion order (add spec tests) #1021

andychu opened this issue Nov 26, 2021 · 4 comments

Comments

@andychu
Copy link
Contributor

andychu commented Nov 26, 2021

This is better for serializing and deserializing, which is great for Oil

Two parts to this

  1. implement it directly in the C++ runtime
  2. in ASDL, the dict type should use collections.OrderedDict under the hood. (maybe rename to map type?)

This will help with implementing qtt read ? So you can just use Dict[Str, List]

And the JSON encoder/decoder

@andychu
Copy link
Contributor Author

andychu commented Nov 29, 2021

Yeah I think we can import or copy some code from collections.OrderedDict in Python, and then "hide" that behind the C++ translation, which will just use regular Dict.

It probably only needs to be in the ASDL compiler? Because that is what generates value__AssocArray which will become value__Dict

@andychu
Copy link
Contributor Author

andychu commented May 31, 2022

Did this in py-yajl on the ENCODE side

oilshell/py-yajl@d10820b

Decoder still needs OrderedDict, hm

andychu pushed a commit that referenced this issue Jun 2, 2022
For ordered dictionaries in Python.  In C++ they will always be ordered.

Part of #1021.  Motivated by JSON,  and the config dialect #951.
andychu pushed a commit that referenced this issue Jun 2, 2022
- This also has a dict ordering problem #1021
- Handling floats would be nice
- Handling eggex too -- that is common
@andychu
Copy link
Contributor Author

andychu commented Jun 6, 2022

  • value_t.AssocArray and Obj can also use OrdererdDict
  • and yes the decode side too

andychu pushed a commit that referenced this issue Jun 11, 2022
@andychu
Copy link
Contributor Author

andychu commented Jul 28, 2022

@andychu andychu closed this as completed Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant