Construct FunctionCreationLocal

Performance Diagrams

Construct FunctionCreationLocal 00100000010000002000000200000030000003000000400000040000005000000500000060000006000000700000070000008000000800000090000009000000100000001000000011000000110000001200000012000000130000001300000014000000140000001500000015000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)1501849688.95192307692307257.0CPython 2.77700339242.31730769230768377.41346761558344Nuitka (master)8700335395.6826923076923360.95946342276375Nuitka (develop)8700335549.0480769230769360.95946342276375Nuitka (factory)Construct FunctionCreationLocalTicks Construct FunctionCreationLocal 00200000020000004000000400000060000006000000800000080000001000000010000000120000001200000014000000140000001600000016000000180000001800000020000000200000002200000022000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)2212101888.95192307692307257.0CPython 3.59552980242.31730769230768397.39840048187517Nuitka (master)10551402395.6826923076923386.24496095488496Nuitka (develop)10551372549.0480769230769386.2452960869091Nuitka (factory)Construct FunctionCreationLocalTicks

Source Code with Construct

def calledRepeatedly():
    # We measure making a local function that will remain unused.
# construct_begin
    def empty():
        pass
# construct_alternative



    return empty


import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Source Code without Construct

def calledRepeatedly():
    # We measure making a local function that will remain unused.
# construct_begin


# construct_alternative
    empty = 1
# construct_end

    return empty


import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Context Diff of Source Code


Construct
Baseline
21 21
22 22
23 def calledRepeatedly(): 23 def calledRepeatedly():
24     # We measure making a local function that will remain unused. 24     # We measure making a local function that will remain unused.
25 # construct_begin 25 # construct_begin
n 26     def empty(): n
27         pass
28 # construct_alternative
29 26
30 27
t t 28 # construct_alternative
29     empty = 1
30 # construct_end
31 31
32     return empty 32     return empty
33 33
34 34
35 import itertools 35 import itertools

Context Diff of Generated Code


Construct
Baseline
32 PyObject *module___main__; 32 PyObject *module___main__;
33 PyDictObject *moduledict___main__; 33 PyDictObject *moduledict___main__;
34 34
35 /* The declarations of module constants used, if any. */ 35 /* The declarations of module constants used, if any. */
36 extern PyObject *const_str_plain___file__; 36 extern PyObject *const_str_plain___file__;
n n 37 static PyObject *const_str_plain_repeat;
37 static PyObject *const_tuple_none_int_pos_50000_tuple; 38 static PyObject *const_tuple_none_int_pos_50000_tuple;
38 static PyObject *const_str_plain_itertools; 39 static PyObject *const_str_plain_itertools;
39 static PyObject *const_str_plain_calledRepeatedly; 40 static PyObject *const_str_plain_calledRepeatedly;
40 extern PyObject *const_int_0; 41 extern PyObject *const_int_0;
41 static PyObject *const_str_angle_module; 42 static PyObject *const_str_angle_module;
42 static PyObject *const_tuple_str_plain_empty_tuple; 43 static PyObject *const_tuple_str_plain_empty_tuple;
43 static PyObject *const_str_digest_47319b3dc6a572f5edac3dc41dc22b2c; 44 static PyObject *const_str_digest_47319b3dc6a572f5edac3dc41dc22b2c;
44 static PyObject *const_str_plain_x; 45 static PyObject *const_str_plain_x;
45 static PyObject *const_str_plain_empty; 46 static PyObject *const_str_plain_empty;
n 46 static PyObject *const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd; n
47 extern PyObject *const_str_plain_print; 47 extern PyObject *const_str_plain_print;
n n 48 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352;
48 extern PyObject *const_str_plain___doc__; 49 extern PyObject *const_str_plain___doc__;
49 extern PyObject *const_str_plain___cached__; 50 extern PyObject *const_str_plain___cached__;
n 50 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352; n
51 extern PyObject *const_tuple_empty; 51 extern PyObject *const_tuple_empty;
n 52 static PyObject *const_str_plain_repeat; n
53 static PyObject *const_int_pos_50000; 52 static PyObject *const_int_pos_50000;
n n 53 extern PyObject *const_int_pos_1;
54 static PyObject *module_filename_obj; 54 static PyObject *module_filename_obj;
55 55
56 /* Indicator if this modules private constants were created yet. */ 56 /* Indicator if this modules private constants were created yet. */
57 static bool constants_created = false; 57 static bool constants_created = false;
58 58
59 /* Function to create module private constants. */ 59 /* Function to create module private constants. */
60 static void createModuleConstants(void) { 60 static void createModuleConstants(void) {
n n 61     const_str_plain_repeat = UNSTREAM_STRING_ASCII(&constant_bin[ 38 ], 6, 1);
61     const_tuple_none_int_pos_50000_tuple = PyTuple_New(2); 62     const_tuple_none_int_pos_50000_tuple = PyTuple_New(2);
62     PyTuple_SET_ITEM(const_tuple_none_int_pos_50000_tuple, 0, Py_None); Py_INCREF(Py_None); 63     PyTuple_SET_ITEM(const_tuple_none_int_pos_50000_tuple, 0, Py_None); Py_INCREF(Py_None);
63     const_int_pos_50000 = PyLong_FromUnsignedLong(50000ul); 64     const_int_pos_50000 = PyLong_FromUnsignedLong(50000ul);
64     PyTuple_SET_ITEM(const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000); Py_INCREF(const_int_pos_50000); 65     PyTuple_SET_ITEM(const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000); Py_INCREF(const_int_pos_50000);
n 65     const_str_plain_itertools = UNSTREAM_STRING_ASCII(&constant_bin[ 38 ], 9, 1); n 66     const_str_plain_itertools = UNSTREAM_STRING_ASCII(&constant_bin[ 44 ], 9, 1);
66     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII(&constant_bin[ 6 ], 16, 1); 67     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII(&constant_bin[ 6 ], 16, 1);
n 67     const_str_angle_module = UNSTREAM_STRING_ASCII(&constant_bin[ 47 ], 8, 0); n 68     const_str_angle_module = UNSTREAM_STRING_ASCII(&constant_bin[ 53 ], 8, 0);
68     const_tuple_str_plain_empty_tuple = PyTuple_New(1); 69     const_tuple_str_plain_empty_tuple = PyTuple_New(1);
n 69     const_str_plain_empty = UNSTREAM_STRING_ASCII(&constant_bin[ 55 ], 5, 1); n 70     const_str_plain_empty = UNSTREAM_STRING_ASCII(&constant_bin[ 61 ], 5, 1);
70     PyTuple_SET_ITEM(const_tuple_str_plain_empty_tuple, 0, const_str_plain_empty); Py_INCREF(const_str_plain_empty); 71     PyTuple_SET_ITEM(const_tuple_str_plain_empty_tuple, 0, const_str_plain_empty); Py_INCREF(const_str_plain_empty);
n 71     const_str_digest_47319b3dc6a572f5edac3dc41dc22b2c = UNSTREAM_STRING_ASCII(&constant_bin[ 60 ], 46, 0); n 72     const_str_digest_47319b3dc6a572f5edac3dc41dc22b2c = UNSTREAM_STRING_ASCII(&constant_bin[ 66 ], 46, 0);
72     const_str_plain_x = UNSTREAM_STRING_ASCII(&constant_bin[ 106 ], 1, 1); 73     const_str_plain_x = UNSTREAM_STRING_ASCII(&constant_bin[ 112 ], 1, 1);
73     const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd = UNSTREAM_STRING_ASCII(&constant_bin[ 107 ], 31, 0);
74     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII(&constant_bin[ 138 ], 3, 0); 74     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII(&constant_bin[ 113 ], 3, 0);
75     const_str_plain_repeat = UNSTREAM_STRING_ASCII(&constant_bin[ 141 ], 6, 1);
76 75
77     constants_created = true; 76     constants_created = true;
78 } 77 }
79 78
80 /* Function to verify module private constants for non-corruption. */ 79 /* Function to verify module private constants for non-corruption. */
88 #endif 87 #endif
89 88
90 // The module code objects. 89 // The module code objects.
91 static PyCodeObject *codeobj_17d748f85e5e9eba5c8e09883c951d05; 90 static PyCodeObject *codeobj_17d748f85e5e9eba5c8e09883c951d05;
92 static PyCodeObject *codeobj_4c1cc9d8683c1f603fb0a1d45419ab65; 91 static PyCodeObject *codeobj_4c1cc9d8683c1f603fb0a1d45419ab65;
n 93 static PyCodeObject *codeobj_518df9e6f4046f9f5e7fdf7a1e91dd4b; n
94 /* For use in "MainProgram.c". */ 92 /* For use in "MainProgram.c". */
95 PyCodeObject *codeobj_main = NULL; 93 PyCodeObject *codeobj_main = NULL;
96 94
97 static void createModuleCodeObjects(void) { 95 static void createModuleCodeObjects(void) {
98     module_filename_obj = const_str_digest_47319b3dc6a572f5edac3dc41dc22b2c; 96     module_filename_obj = const_str_digest_47319b3dc6a572f5edac3dc41dc22b2c;
99     codeobj_17d748f85e5e9eba5c8e09883c951d05 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, const_str_angle_module, const_tuple_empty, 0, 0, 0); 97     codeobj_17d748f85e5e9eba5c8e09883c951d05 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, const_str_angle_module, const_tuple_empty, 0, 0, 0);
100     codeobj_4c1cc9d8683c1f603fb0a1d45419ab65 = MAKE_CODEOBJECT(module_filename_obj, 23, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, const_str_plain_calledRepeatedly, const_tuple_str_plain_empty_tuple, 0, 0, 0); 98     codeobj_4c1cc9d8683c1f603fb0a1d45419ab65 = MAKE_CODEOBJECT(module_filename_obj, 23, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, const_str_plain_calledRepeatedly, const_tuple_str_plain_empty_tuple, 0, 0, 0);
n 101     codeobj_518df9e6f4046f9f5e7fdf7a1e91dd4b = MAKE_CODEOBJECT(module_filename_obj, 26, CO_NOFREE, const_str_plain_empty, const_tuple_empty, 0, 0, 0); n
102 } 99 }
103 100
104 // The module function declarations. 101 // The module function declarations.
105 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(); 102 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly();
n 106   n
107  
108 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty();
109 103
110 104
111 // The module function definitions. 105 // The module function definitions.
112 static PyObject *impl___main__$$$function_1_calledRepeatedly(struct Nuitka_FunctionObject const *self, PyObject **python_pars) { 106 static PyObject *impl___main__$$$function_1_calledRepeatedly(struct Nuitka_FunctionObject const *self, PyObject **python_pars) {
113     // Preserve error status for checks 107     // Preserve error status for checks
114 #ifndef __NUITKA_NO_ASSERT__ 108 #ifndef __NUITKA_NO_ASSERT__
115     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 109     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
116 #endif 110 #endif
117 111
118     // Local variable declarations. 112     // Local variable declarations.
n 119     PyObject *var_empty = NULL; n
120     PyObject *tmp_return_value = NULL; 113     PyObject *tmp_return_value = NULL;
121 114
122     // Actual function body. 115     // Actual function body.
n 123     { n 116     tmp_return_value = const_int_pos_1;
124         PyObject *tmp_assign_source_1;
125  
126  
127         tmp_assign_source_1 = MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty();
128  
129         assert(var_empty == NULL);
130         var_empty = tmp_assign_source_1;
131     }
132     // Tried code:
133     CHECK_OBJECT(var_empty);
134     tmp_return_value = var_empty;
135     Py_INCREF(tmp_return_value); 117     Py_INCREF(tmp_return_value);
n 136     goto try_return_handler_1; n
137     NUITKA_CANNOT_GET_HERE("tried codes exits in all cases");
138     return NULL;
139     // Return handler code:
140     try_return_handler_1:;
141     CHECK_OBJECT(var_empty);
142     Py_DECREF(var_empty);
143     var_empty = NULL;
144  
145     goto function_return_exit; 118     goto function_return_exit;
n 146     // End of try: n
147 119
148     NUITKA_CANNOT_GET_HERE("Return statement must have exited already."); 120     NUITKA_CANNOT_GET_HERE("Return statement must have exited already.");
149     return NULL; 121     return NULL;
150 122
151 123
183 155
184     return (PyObject *)result; 156     return (PyObject *)result;
185 } 157 }
186 158
187 159
n 188   n
189 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty() {
190     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
191         NULL,
192         const_str_plain_empty,
193 #if PYTHON_VERSION >= 300
194         const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd,
195 #endif
196         codeobj_518df9e6f4046f9f5e7fdf7a1e91dd4b,
197         NULL,
198 #if PYTHON_VERSION >= 300
199         NULL,
200         NULL,
201 #endif
202         module___main__,
203         NULL,
204         NULL,
205         0
206     );
207  
208     return (PyObject *)result;
209 }
210  
211  
212 extern PyObject *const_str_plain___compiled__; 160 extern PyObject *const_str_plain___compiled__;
213 161
214 extern PyObject *const_str_plain___package__; 162 extern PyObject *const_str_plain___package__;
215 extern PyObject *const_str_empty; 163 extern PyObject *const_str_empty;
216 164
236 #ifdef _NUITKA_PLUGIN_DILL_ENABLED 184 #ifdef _NUITKA_PLUGIN_DILL_ENABLED
237 // Provide a way to create find a function via its C code and create it back 185 // Provide a way to create find a function via its C code and create it back
238 // in another process, useful for multiprocessing extensions like dill 186 // in another process, useful for multiprocessing extensions like dill
239 187
240 function_impl_code functable___main__[] = { 188 function_impl_code functable___main__[] = {
t 241     NULL, t
242     impl___main__$$$function_1_calledRepeatedly, 189     impl___main__$$$function_1_calledRepeatedly,
243     NULL 190     NULL
244 }; 191 };
245 192
246 static char const *_reduce_compiled_function_argnames[] = { 193 static char const *_reduce_compiled_function_argnames[] = {