-
Notifications
You must be signed in to change notification settings - Fork 55
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
Suggestion: use standard dict with Python >= 3.7 #144
Comments
Switching between two dict implementations depending on Python version is the additional maintainance burden. Do you have performance numbers not for dict vs OrderedDict but for |
I fully agree with this. So it's just a suggestion.
No, I don't have those measurements. |
Please do it. The boost evidence is crucial for making the decision. |
Here you are:
As you can see, the performance of using the standard dictionary has not changed much, but the memory consumption is significantly reduced. |
@mpyatishev the |
The library uses I personally don't want to work on it but will be happy to review PR that replaces OrderedDict with structures similar to the approach used by |
I believe this substitution is unnecessary. In the current project, __cache needs to not only preserve the stored order but also adjust the existing order based on this. This is precisely the correct usage of OrderedDict after version 3.7 (using move_to_end() and popitem()).
|
Since the order of elements in the dictionary is guaranteed in python 3.7, it would be good to use a standard dictionary instead of OrderedDict - this will save memory and slightly improve performance. Though, probably, at the size of 128 elements it does not matter much.
In addition, it seems that there is an error in the _cache_hit method: probably, in this case, the key should be moved to the beginning, not the end of the dictionary. Although I do not really understand what in general can seriously affect the movement of the key on small amounts of data.
The text was updated successfully, but these errors were encountered: