diff --git a/python/collections.py b/python/collections.py index 654b50c6..00a9e739 100644 --- a/python/collections.py +++ b/python/collections.py @@ -43,6 +43,10 @@ class deque: self.tail.prev = self.head self.size = 0 + def extend(self, iterable): + for value in iterable: + self.append(value) + def append(self, value): node = _LinkedListNode(self.tail.prev, self.tail, value) self.tail.prev.next = node diff --git a/src/pocketpy.h b/src/pocketpy.h index 8411bde0..a739d553 100644 --- a/src/pocketpy.h +++ b/src/pocketpy.h @@ -449,6 +449,15 @@ inline void init_builtins(VM* _vm) { for(i64 i = 0; i < n; i++) ss << self.sv(); return VAR(ss.str()); }); + + _vm->bind_method<1>("str", "__rmul__", [](VM* vm, ArgsView args) { + const Str& self = _CAST(Str&, args[0]); + i64 n = CAST(i64, args[1]); + std::stringstream ss; + for(i64 i = 0; i < n; i++) ss << self.sv(); + return VAR(ss.str()); + }); + _vm->bind__contains__(_vm->tp_str, [](VM* vm, PyObject* lhs, PyObject* rhs) { const Str& self = _CAST(Str&, lhs); return VAR(self.index(CAST(Str&, rhs)) != -1);