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
561f83c9
Commit
561f83c9
authored
10 years ago
by
Damien George
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of github.com:micropython/micropython
parents
38ae014e
0fc4775c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
py/objfloat.c
+1
-1
1 addition, 1 deletion
py/objfloat.c
py/runtime.c
+5
-1
5 additions, 1 deletion
py/runtime.c
py/sequence.c
+18
-16
18 additions, 16 deletions
py/sequence.c
tests/basics/tuple_compare.py
+5
-0
5 additions, 0 deletions
tests/basics/tuple_compare.py
with
29 additions
and
18 deletions
py/objfloat.c
+
1
−
1
View file @
561f83c9
...
...
@@ -30,7 +30,7 @@ STATIC void float_print(void (*print)(void *env, const char *fmt, ...), void *en
}
#else
char
buf
[
32
];
sprintf
(
buf
,
"%.
8
g"
,
(
double
)
o
->
value
);
sprintf
(
buf
,
"%.
17
g"
,
(
double
)
o
->
value
);
print
(
env
,
buf
);
if
(
strchr
(
buf
,
'.'
)
==
NULL
)
{
// Python floats always have decimal point
...
...
This diff is collapsed.
Click to expand it.
py/runtime.c
+
5
−
1
View file @
561f83c9
...
...
@@ -1060,10 +1060,14 @@ import_error:
void
mp_import_all
(
mp_obj_t
module
)
{
DEBUG_printf
(
"import all %p
\n
"
,
module
);
// TODO: Support __all__
mp_map_t
*
map
=
mp_obj_dict_get_map
(
mp_obj_module_get_globals
(
module
));
for
(
uint
i
=
0
;
i
<
map
->
alloc
;
i
++
)
{
if
(
MP_MAP_SLOT_IS_FILLED
(
map
,
i
))
{
mp_store_name
(
MP_OBJ_QSTR_VALUE
(
map
->
table
[
i
].
key
),
map
->
table
[
i
].
value
);
qstr
name
=
MP_OBJ_QSTR_VALUE
(
map
->
table
[
i
].
key
);
if
(
*
qstr_str
(
name
)
!=
'_'
)
{
mp_store_name
(
name
,
map
->
table
[
i
].
value
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
py/sequence.c
+
18
−
16
View file @
561f83c9
#include
<assert.h>
#include
<stdbool.h>
#include
<string.h>
...
...
@@ -108,31 +109,32 @@ bool mp_seq_cmp_objs(int op, const mp_obj_t *items1, uint len1, const mp_obj_t *
}
int
len
=
len1
<
len2
?
len1
:
len2
;
bool
eq_status
=
true
;
// empty lists are equal
bool
rel_status
;
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
eq_status
=
mp_obj_equal
(
items1
[
i
],
items2
[
i
]);
if
(
op
==
MP_BINARY_OP_EQUAL
&&
!
eq_status
)
{
return
fals
e
;
// If current elements equal, can't decide anything - go on
if
(
mp_obj_equal
(
items1
[
i
],
items2
[
i
])
)
{
continu
e
;
}
rel_status
=
(
mp_binary_op
(
op
,
items1
[
i
],
items2
[
i
])
==
mp_const_true
);
if
(
!
eq_status
&&
!
rel_status
)
{
// Othewise, if they are not equal, we can have final decision based on them
if
(
op
==
MP_BINARY_OP_EQUAL
)
{
// In particular, if we are checking for equality, here're the answer
return
false
;
}
// Otherwise, application of relation op gives the answer
return
(
mp_binary_op
(
op
,
items1
[
i
],
items2
[
i
])
==
mp_const_true
);
}
// If we had tie in the last element...
if
(
eq_status
)
{
// ... and we have lists of different lengths...
if
(
len1
!=
len2
)
{
if
(
len1
<
len2
)
{
// ... then longer list length wins (we deal only with >)
return
false
;
}
}
else
if
(
op
==
MP_BINARY_OP_MORE
)
{
// Otherwise, if we have strict relation, equality means failure
// ... and we have lists of different lengths...
if
(
len1
!=
len2
)
{
if
(
len1
<
len2
)
{
// ... then longer list length wins (we deal only with >)
return
false
;
}
}
else
if
(
op
==
MP_BINARY_OP_MORE
)
{
// Otherwise, if we have strict relation, sequence equality means failure
return
false
;
}
return
true
;
...
...
This diff is collapsed.
Click to expand it.
tests/basics/tuple_compare.py
+
5
−
0
View file @
561f83c9
...
...
@@ -48,3 +48,8 @@ print((1,) <= (1, 0,))
print
((
1
,)
<=
(
1
,
-
1
,))
print
((
1
,
0
,)
<=
(
1
,))
print
((
1
,
-
1
,)
<=
(
1
,))
print
((
10
,
0
)
>
(
1
,
1
))
print
((
10
,
0
)
<
(
1
,
1
))
print
((
0
,
0
,
10
,
0
)
>
(
0
,
0
,
1
,
1
))
print
((
0
,
0
,
10
,
0
)
<
(
0
,
0
,
1
,
1
))
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