diff --git a/py/modsys.c b/py/modsys.c
index ee6f8686e014cd5e3fef60660226c09551df11f7..b7d55fdcc66a8195afa84765266278706f8b9c5b 100644
--- a/py/modsys.c
+++ b/py/modsys.c
@@ -4,6 +4,7 @@
  * The MIT License (MIT)
  *
  * Copyright (c) 2013, 2014 Damien P. George
+ * Copyright (c) 2014-2017 Paul Sokolovsky
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -31,8 +32,11 @@
 #include "py/objtuple.h"
 #include "py/objstr.h"
 #include "py/objint.h"
+#include "py/objtype.h"
 #include "py/stream.h"
 #include "py/smallint.h"
+#include "py/runtime0.h"
+#include "py/runtime.h"
 
 #if MICROPY_PY_SYS
 
@@ -143,6 +147,11 @@ STATIC mp_obj_t mp_sys_exc_info(void) {
 MP_DEFINE_CONST_FUN_OBJ_0(mp_sys_exc_info_obj, mp_sys_exc_info);
 #endif
 
+STATIC mp_obj_t mp_sys_getsizeof(mp_obj_t obj) {
+    return mp_unary_op(MP_UNARY_OP_SIZEOF, obj);
+}
+MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_getsizeof_obj, mp_sys_getsizeof);
+
 STATIC const mp_rom_map_elem_t mp_module_sys_globals_table[] = {
     { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_sys) },
 
@@ -192,6 +201,9 @@ STATIC const mp_rom_map_elem_t mp_module_sys_globals_table[] = {
     #if MICROPY_PY_SYS_EXC_INFO
     { MP_ROM_QSTR(MP_QSTR_exc_info), MP_ROM_PTR(&mp_sys_exc_info_obj) },
     #endif
+    #if MICROPY_PY_SYS_GETSIZEOF
+    { MP_ROM_QSTR(MP_QSTR_getsizeof), MP_ROM_PTR(&mp_sys_getsizeof_obj) },
+    #endif
 
     /*
      * Extensions to CPython
diff --git a/py/mpconfig.h b/py/mpconfig.h
index fb507a503e645953978a3cff10992de0ad4c5c2d..0e76a1ff5e74b13f292764f774d2bea6a07269a8 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -944,6 +944,11 @@ typedef double mp_float_t;
 #define MICROPY_PY_SYS_EXIT (1)
 #endif
 
+// Whether to provide "sys.getsizeof" function
+#ifndef MICROPY_PY_SYS_GETSIZEOF
+#define MICROPY_PY_SYS_GETSIZEOF (0)
+#endif
+
 // Whether to provide sys.{stdin,stdout,stderr} objects
 #ifndef MICROPY_PY_SYS_STDFILES
 #define MICROPY_PY_SYS_STDFILES (0)
diff --git a/py/objdict.c b/py/objdict.c
index a272ebdb633f9b1d221c833daec04879c560d7a9..f6357a905bb394a609bb67e3ee948fec1edffdb2 100644
--- a/py/objdict.c
+++ b/py/objdict.c
@@ -105,6 +105,12 @@ STATIC mp_obj_t dict_unary_op(mp_uint_t op, mp_obj_t self_in) {
     switch (op) {
         case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->map.used != 0);
         case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->map.used);
+        #if MICROPY_PY_SYS_GETSIZEOF
+        case MP_UNARY_OP_SIZEOF: {
+            size_t sz = sizeof(*self) + sizeof(*self->map.table) * self->map.alloc;
+            return MP_OBJ_NEW_SMALL_INT(sz);
+        }
+        #endif
         default: return MP_OBJ_NULL; // op not supported
     }
 }
diff --git a/py/objlist.c b/py/objlist.c
index ba1c506771dbbd5d13f0a119bc3b1c40db4b0bb7..5957c9d4ad40a9294af62e81b29ea29717ce3266 100644
--- a/py/objlist.c
+++ b/py/objlist.c
@@ -104,6 +104,12 @@ STATIC mp_obj_t list_unary_op(mp_uint_t op, mp_obj_t self_in) {
     switch (op) {
         case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->len != 0);
         case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->len);
+        #if MICROPY_PY_SYS_GETSIZEOF
+        case MP_UNARY_OP_SIZEOF: {
+            size_t sz = sizeof(*self) + sizeof(mp_obj_t) * self->alloc;
+            return MP_OBJ_NEW_SMALL_INT(sz);
+        }
+        #endif
         default: return MP_OBJ_NULL; // op not supported
     }
 }
diff --git a/py/objtype.c b/py/objtype.c
index a258915f34baee0953fd48cd0d03c92f1148a60c..87c0cc9e5c1b6fd3d062b213f5c5189a2e6866d0 100644
--- a/py/objtype.c
+++ b/py/objtype.c
@@ -339,11 +339,27 @@ const qstr mp_unary_op_method_name[] = {
     [MP_UNARY_OP_NEGATIVE] = MP_QSTR___neg__,
     [MP_UNARY_OP_INVERT] = MP_QSTR___invert__,
     #endif
+    #if MICROPY_PY_SYS_GETSIZEOF
+    [MP_UNARY_OP_SIZEOF] = MP_QSTR_getsizeof,
+    #endif
     [MP_UNARY_OP_NOT] = MP_QSTR_, // don't need to implement this, used to make sure array has full size
 };
 
 STATIC mp_obj_t instance_unary_op(mp_uint_t op, mp_obj_t self_in) {
     mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in);
+
+    #if MICROPY_PY_SYS_GETSIZEOF
+    if (MP_UNLIKELY(op == MP_UNARY_OP_SIZEOF)) {
+        // TODO: This doesn't count inherited objects (self->subobj)
+        const mp_obj_type_t *native_base;
+        size_t num_native_bases = instance_count_native_bases(mp_obj_get_type(self_in), &native_base);
+
+        size_t sz = sizeof(*self) + sizeof(*self->subobj) * num_native_bases
+            + sizeof(*self->members.table) * self->members.alloc;
+        return MP_OBJ_NEW_SMALL_INT(sz);
+    }
+    #endif
+
     qstr op_name = mp_unary_op_method_name[op];
     /* Still try to lookup native slot
     if (op_name == 0) {
diff --git a/py/runtime0.h b/py/runtime0.h
index d22c2fabe6e7689a066aa34575327621cec02685..703c950f2d09e5cc90900f472f98dbc7d4def711 100644
--- a/py/runtime0.h
+++ b/py/runtime0.h
@@ -50,6 +50,7 @@ typedef enum {
     MP_UNARY_OP_NEGATIVE,
     MP_UNARY_OP_INVERT,
     MP_UNARY_OP_NOT,
+    MP_UNARY_OP_SIZEOF, // for sys.getsizeof()
 } mp_unary_op_t;
 
 typedef enum {
diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp
index 390ff1669d2a5f79cfafb6bf53cb0ebcbb5bc371..ab638a632dce32308bab8243d23bfc8c4f8d600e 100644
--- a/tests/unix/extra_coverage.py.exp
+++ b/tests/unix/extra_coverage.py.exp
@@ -25,7 +25,8 @@ ame__
 __name__        path            argv            version
 version_info    implementation  platform        byteorder
 maxsize         exit            stdin           stdout
-stderr          modules         exc_info        print_exception
+stderr          modules         exc_info        getsizeof
+print_exception
 ementation
 # attrtuple
 (start=1, stop=2, step=3)
diff --git a/unix/mpconfigport_coverage.h b/unix/mpconfigport_coverage.h
index 5fc8d7107a7a221252632e5f7cf16c60d1d3965c..a9e0a38fa0dc3bf5b1019ec50a02b6ab8a5245c5 100644
--- a/unix/mpconfigport_coverage.h
+++ b/unix/mpconfigport_coverage.h
@@ -37,6 +37,7 @@
 #define MICROPY_PY_DELATTR_SETATTR     (1)
 #define MICROPY_PY_BUILTINS_HELP       (1)
 #define MICROPY_PY_BUILTINS_HELP_MODULES (1)
+#define MICROPY_PY_SYS_GETSIZEOF       (1)
 #define MICROPY_PY_URANDOM_EXTRA_FUNCS (1)
 #define MICROPY_PY_IO_BUFFEREDWRITER (1)
 #undef MICROPY_VFS_FAT