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

Use dict instead of OrderedDict for python 3.6 #252

Closed
aymanhs opened this issue Jun 17, 2020 · 9 comments · Fixed by #295
Closed

Use dict instead of OrderedDict for python 3.6 #252

aymanhs opened this issue Jun 17, 2020 · 9 comments · Fixed by #295

Comments

@aymanhs
Copy link

aymanhs commented Jun 17, 2020

For Python >= 3.6, dictionary are Sorted by insertion order, so avoid the use of OrderedDict for those python versions.

@epatters
Copy link

epatters commented Jul 12, 2020

The main function parse has a dict_constructor keyword argument useful for this purpose.

@danielloader
Copy link

Is this available in the pypi package or the source package only?

@ehn-pkalinowski
Copy link

it is in pypi

@TomDufall
Copy link

This is a CPython implementation detail for Python 3.6, although I think it's part of the dict spec from 3.7 onwards?

@soustruh
Copy link

soustruh commented Jul 24, 2021

Yes it is. 👍

Ordered dictionaries are just like regular dictionaries but have some extra capabilities relating to ordering operations. They have become less important now that the built-in dict class gained the ability to remember insertion order (this new behavior became guaranteed in Python 3.7).

https://docs.python.org/3.7/library/collections.html?highlight=ordereddict#ordereddict-objects

@endlisnis
Copy link

And since Python3.6 is now end-of-life (https://pythonspeed.com/articles/stop-using-python-3.6), this project should just blindly use "dict" instead of "OrderedDict".

@manngo
Copy link

manngo commented Jan 27, 2022

The main function parse has a dict_constructor keyword argument useful for this purpose.

Is that documented? How would I use that?

@gotofritz
Copy link

@manngo you can see an example here

self.assertEqual(parse(xml, force_list=force_list, dict_constructor=dict), expectedResult)

@manngo
Copy link

manngo commented Mar 24, 2022

@gotofritz Thanks, that worked. It makes the result much easier to work with.

@manngo you can see an example here

self.assertEqual(parse(xml, force_list=force_list, dict_constructor=dict), expectedResult)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants