-
Notifications
You must be signed in to change notification settings - Fork 15
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 with non-string keys get serialized wrong #4
Comments
Just want to make one note on this that isn't in the original issue/discussion: This suggestion would turn tuples, which are hashable, into lists, which are not. This means that if someone reports a dictionary that has tuples as keys to NetLogo, and then pass them right back into python, it will fail because the keys are now unhashable lists. It would be quite confusing to people unless they are aware of this issue. (To be fair, most people who work with Python are...) One option would be to iterate over keys in the extension, and turn all keys that are unhashable into a hashable object before creating the dictionary in python. But it seems a bit dangerous to make assumptions about what people want their data types to be, too. |
Good call. Worth noting we don't attempt to convert anything to dictionaries right now. e.g.:
It's up to the user to then wrap So the only real option I see is to make tuples are default iterable target instead of lists, but that doesn't seem reasonable to me. |
I definitely agree with that, and it makes sense to just make people be explicit about calling |
Copied from with more discussion at: qiemem/PythonExtension#6
Some examples:
While JSON is restricted to string keys, we are not. We need to hijack JSON's dict serialization to turn them into a list of pairs instead.
The text was updated successfully, but these errors were encountered: