Skip to content

Commit ebde0b8

Browse files
committed
Tiny optimisation in objlist.c; a new test for inheritance.
1 parent a8a6db2 commit ebde0b8

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

py/objlist.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ static mp_obj_t list_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp
4444
switch (n_args) {
4545
case 0:
4646
// return a new, empty list
47-
return rt_build_list(0, NULL);
47+
return mp_obj_new_list(0, NULL);
4848

4949
case 1:
5050
{
5151
// make list from iterable
5252
mp_obj_t iterable = rt_getiter(args[0]);
53-
mp_obj_t list = rt_build_list(0, NULL);
53+
mp_obj_t list = mp_obj_new_list(0, NULL);
5454
mp_obj_t item;
5555
while ((item = rt_iternext(iterable)) != mp_const_stop_iteration) {
56-
rt_list_append(list, item);
56+
mp_obj_list_append(list, item);
5757
}
5858
return list;
5959
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class A:
2+
def __init__(self, x):
3+
print('A init', x)
4+
self.x = x
5+
6+
def f(self):
7+
print(self.x, self.y)
8+
9+
class B(A):
10+
def __init__(self, x, y):
11+
A.__init__(self, x)
12+
print('B init', x, y)
13+
self.y = y
14+
15+
def g(self):
16+
print(self.x, self.y)
17+
18+
A(1)
19+
b = B(1, 2)
20+
b.f()
21+
b.g()

0 commit comments

Comments
 (0)