Tiny optimisation in objlist.c; a new test for inheritance.
This commit is contained in:
parent
a8a6db2a1d
commit
ebde0b8a09
@ -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) {
|
||||
case 0:
|
||||
// return a new, empty list
|
||||
return rt_build_list(0, NULL);
|
||||
return mp_obj_new_list(0, NULL);
|
||||
|
||||
case 1:
|
||||
{
|
||||
// make list from iterable
|
||||
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;
|
||||
while ((item = rt_iternext(iterable)) != mp_const_stop_iteration) {
|
||||
rt_list_append(list, item);
|
||||
mp_obj_list_append(list, item);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
21
tests/basics/tests/class_inherit1.py
Normal file
21
tests/basics/tests/class_inherit1.py
Normal file
@ -0,0 +1,21 @@
|
||||
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()
|
Loading…
Reference in New Issue
Block a user