Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
3131053e
Commit
3131053e
authored
9 years ago
by
Mark Anthony Palomer
Committed by
Paul Sokolovsky
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
py/objdict: Implemented OrderedDict equality check.
parent
91031b60
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
py/objdict.c
+10
-2
10 additions, 2 deletions
py/objdict.c
with
10 additions
and
2 deletions
py/objdict.c
+
10
−
2
View file @
3131053e
...
...
@@ -119,8 +119,16 @@ STATIC mp_obj_t dict_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
case
MP_BINARY_OP_EQUAL
:
{
#if MICROPY_PY_COLLECTIONS_ORDEREDDICT
if
(
MP_UNLIKELY
(
MP_OBJ_IS_TYPE
(
lhs_in
,
&
mp_type_ordereddict
)
&&
MP_OBJ_IS_TYPE
(
rhs_in
,
&
mp_type_ordereddict
)))
{
//TODO: implement
return
MP_OBJ_NULL
;
// Iterate through both dictionaries simultaneously and compare keys and values.
mp_obj_dict_t
*
rhs
=
MP_OBJ_TO_PTR
(
rhs_in
);
mp_uint_t
c1
=
0
,
c2
=
0
;
mp_map_elem_t
*
e1
=
dict_iter_next
(
o
,
&
c1
),
*
e2
=
dict_iter_next
(
rhs
,
&
c2
);
for
(;
e1
!=
NULL
&&
e2
!=
NULL
;
e1
=
dict_iter_next
(
o
,
&
c1
),
e2
=
dict_iter_next
(
rhs
,
&
c2
))
{
if
(
!
mp_obj_equal
(
e1
->
key
,
e2
->
key
)
||
!
mp_obj_equal
(
e1
->
value
,
e2
->
value
))
{
return
mp_const_false
;
}
}
return
e1
==
NULL
&&
e2
==
NULL
?
mp_const_true
:
mp_const_false
;
}
else
#endif
if
(
MP_OBJ_IS_TYPE
(
rhs_in
,
&
mp_type_dict
))
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment