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
GitLab 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
ebde0b8a
Commit
ebde0b8a
authored
Jan 19, 2014
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
Tiny optimisation in objlist.c; a new test for inheritance.
parent
a8a6db2a
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
py/objlist.c
+3
-3
3 additions, 3 deletions
py/objlist.c
tests/basics/tests/class_inherit1.py
+21
-0
21 additions, 0 deletions
tests/basics/tests/class_inherit1.py
with
24 additions
and
3 deletions
py/objlist.c
+
3
−
3
View file @
ebde0b8a
...
@@ -44,16 +44,16 @@ static mp_obj_t list_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp
...
@@ -44,16 +44,16 @@ static mp_obj_t list_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp
switch
(
n_args
)
{
switch
(
n_args
)
{
case
0
:
case
0
:
// return a new, empty list
// return a new, empty list
return
rt_build
_list
(
0
,
NULL
);
return
mp_obj_new
_list
(
0
,
NULL
);
case
1
:
case
1
:
{
{
// make list from iterable
// make list from iterable
mp_obj_t
iterable
=
rt_getiter
(
args
[
0
]);
mp_obj_t
iterable
=
rt_getiter
(
args
[
0
]);
mp_obj_t
list
=
rt_build
_list
(
0
,
NULL
);
mp_obj_t
list
=
mp_obj_new
_list
(
0
,
NULL
);
mp_obj_t
item
;
mp_obj_t
item
;
while
((
item
=
rt_iternext
(
iterable
))
!=
mp_const_stop_iteration
)
{
while
((
item
=
rt_iternext
(
iterable
))
!=
mp_const_stop_iteration
)
{
rt
_list_append
(
list
,
item
);
mp_obj
_list_append
(
list
,
item
);
}
}
return
list
;
return
list
;
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/basics/tests/class_inherit1.py
0 → 100644
+
21
−
0
View file @
ebde0b8a
class
A
:
def
__init__
(
self
,
x
):
print
(
'
A init
'
,
x
)
self
.
x
=
x
def
f
(
self
):
print
(
self
.
x
,
self
.
y
)
class
B
(
A
):
def
__init__
(
self
,
x
,
y
):
A
.
__init__
(
self
,
x
)
print
(
'
B init
'
,
x
,
y
)
self
.
y
=
y
def
g
(
self
):
print
(
self
.
x
,
self
.
y
)
A
(
1
)
b
=
B
(
1
,
2
)
b
.
f
()
b
.
g
()
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