Skip to content

Commit 346aacf

Browse files
committed
unix: fast: Set initial module dict size big to have high pystone score.
For this, introduce MICROPY_MODULE_DICT_SIZE config setting.
1 parent ff8d0e0 commit 346aacf

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

py/mpconfig.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@
100100
#define MICROPY_ALLOC_PATH_MAX (512)
101101
#endif
102102

103+
// Initial size of module dict
104+
#ifndef MICROPY_MODULE_DICT_SIZE
105+
#define MICROPY_MODULE_DICT_SIZE (1)
106+
#endif
107+
103108
/*****************************************************************************/
104109
/* Micro Python emitters */
105110

py/objmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ mp_obj_t mp_obj_new_module(qstr module_name) {
9696
mp_obj_module_t *o = m_new_obj(mp_obj_module_t);
9797
o->base.type = &mp_type_module;
9898
o->name = module_name;
99-
o->globals = mp_obj_new_dict(1);
99+
o->globals = mp_obj_new_dict(MICROPY_MODULE_DICT_SIZE);
100100

101101
// store __name__ entry in the module
102102
mp_obj_dict_store(o->globals, MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(module_name));

unix/mpconfigport_fast.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@
3030

3131
#include <mpconfigport.h>
3232
#define MICROPY_PY___FILE__ (0)
33+
// 91 is a magic number proposed by @dpgeorge, which make pystone run ~ at tie
34+
// with CPython 3.4.
35+
#define MICROPY_MODULE_DICT_SIZE (91)

0 commit comments

Comments
 (0)