sequence.c: Start to refactor sequence operations for reuse among types.
diff --git a/py/obj.h b/py/obj.h
index d7154a7..c2ce325 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -376,3 +376,6 @@
     mp_obj_base_t base;
     mp_obj_t fun;
 } mp_obj_classmethod_t;
+
+// sequence helpers
+void mp_seq_multiply(const void *items, uint item_sz, uint len, uint times, void *dest);
diff --git a/py/objlist.c b/py/objlist.c
index 0ad7b68..8043842 100644
--- a/py/objlist.c
+++ b/py/objlist.c
@@ -153,13 +153,8 @@
                 return NULL;
             }
             int n = MP_OBJ_SMALL_INT_VALUE(rhs);
-            int len = o->len;
-            mp_obj_list_t *s = list_new(len * n);
-            mp_obj_t *dest = s->items;
-            for (int i = 0; i < n; i++) {
-                memcpy(dest, o->items, sizeof(mp_obj_t) * len);
-                dest += len;
-            }
+            mp_obj_list_t *s = list_new(o->len * n);
+            mp_seq_multiply(o->items, sizeof(*o->items), o->len, n, s->items);
             return s;
         }
         case RT_COMPARE_OP_EQUAL:
diff --git a/py/py.mk b/py/py.mk
index ce5169f..6ab1ee3 100644
--- a/py/py.mk
+++ b/py/py.mk
@@ -97,6 +97,7 @@
 	objstr.o \
 	objtuple.o \
 	objtype.o \
+	sequence.o \
 	stream.o \
 	builtin.o \
 	builtinimport.o \
diff --git a/py/sequence.c b/py/sequence.c
new file mode 100644
index 0000000..af3c61a
--- /dev/null
+++ b/py/sequence.c
@@ -0,0 +1,25 @@
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <assert.h>
+
+#include "nlr.h"
+#include "misc.h"
+#include "mpconfig.h"
+#include "mpqstr.h"
+#include "obj.h"
+#include "map.h"
+#include "runtime0.h"
+#include "runtime.h"
+
+// Helpers for sequence types
+
+// Implements backend of sequence * integer operation. Assumes elements are
+// memory-adjacent in sequence.
+void mp_seq_multiply(const void *items, uint item_sz, uint len, uint times, void *dest) {
+    for (int i = 0; i < times; i++) {
+        uint copy_sz = item_sz * len;
+        memcpy(dest, items, copy_sz);
+        dest = (char*)dest + copy_sz;
+    }
+}