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
Fixed #30159 -- Removed obsolete use of OrderedDict with Python 3.6+. #10945
Conversation
django/contrib/admin/options.py
Outdated
(name, (func, name, desc)) | ||
for func, name, desc in actions | ||
) | ||
# Convert the actions into a dictionary keyed by name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe that comment could be removed as the dict comprehension seems somewhat obvious.
django/core/serializers/pyyaml.py
Outdated
@@ -35,6 +35,10 @@ def represent_ordered_dict(self, data): | |||
DjangoSafeDumper.add_representer(decimal.Decimal, DjangoSafeDumper.represent_decimal) | |||
DjangoSafeDumper.add_representer(collections.OrderedDict, DjangoSafeDumper.represent_ordered_dict) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would chop the blank line.
((COMPILED_REGEX_TYPE, RegexObject), RegexSerializer), | ||
(uuid.UUID, UUIDSerializer), | ||
]) | ||
_registry = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would restore the "some of these are order-dependent." comment that was removed in 7d3b389 as it may not be obvious without OrderedDict.
f8cada4
to
d68c913
Compare
Dicts preserve order since Python 3.6.
d68c913
to
24b82cd
Compare
Thanks Tim. |
Ticket #30159.
Follows on from #10894 (comment).
Use of
OrderedDict
remains in two places:django.core.cache.backends.locmem
-- usesOrderedDict.move_to_end()
.django.core.serializers.pyyaml
-- retain ability to serializeOrderedDict
.Some observations:
DeclarativeFieldsMetaclass.__prepare__()
as the class namespace is initialised as an empty ordered mapping.object_pairs_hook
parameter tojson.loads()
inManifestFilesMixin.load_manifest()
asdict
is the default.django.core.serializers.pyyaml
because dictionary items are sorted by key, see Allow to turn off sorting keys in Dumper yaml/pyyaml#143.Query.annotations
andQuery.extra
are simplified because it is no longer necessary to instantiate anOrderedDict
lazily.queries.tests.Queries1Tests.test_ticket2902
is obsolete and is removed.