Construct FunctionCreationLocal

Performance Diagrams

Construct FunctionCreationLocal 00200000020000004000000400000060000006000000800000080000001000000010000000120000001200000014000000140000001600000016000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)1717225788.95192307692307257.0CPython 2.77850328242.31730769230768391.14614457449056Nuitka (master)7949656395.6826923076923389.71677644174736Nuitka (develop)7950321549.0480769230769389.70720683591344Nuitka (factory)Construct FunctionCreationLocalTicks Construct FunctionCreationLocal 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)2502587188.95192307692307257.0CPython 3.59300831242.31730769230768412.2752872294558Nuitka (master)9600834395.6826923076923409.31293851716646Nuitka (develop)9600699549.0480769230769409.31427156075654Nuitka (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
30 PyObject *module___main__; 30 PyObject *module___main__;
31 PyDictObject *moduledict___main__; 31 PyDictObject *moduledict___main__;
32 32
33 /* The declarations of module constants used, if any. */ 33 /* The declarations of module constants used, if any. */
34 extern PyObject *const_str_plain___file__; 34 extern PyObject *const_str_plain___file__;
n n 35 static PyObject *const_str_plain_repeat;
35 static PyObject *const_tuple_none_int_pos_50000_tuple; 36 static PyObject *const_tuple_none_int_pos_50000_tuple;
36 static PyObject *const_str_plain_itertools; 37 static PyObject *const_str_plain_itertools;
37 static PyObject *const_str_plain_calledRepeatedly; 38 static PyObject *const_str_plain_calledRepeatedly;
38 static PyObject *const_str_digest_3787adaddea590b1e85379b441a77dfe; 39 static PyObject *const_str_digest_3787adaddea590b1e85379b441a77dfe;
39 extern PyObject *const_int_0; 40 extern PyObject *const_int_0;
40 static PyObject *const_str_angle_module; 41 static PyObject *const_str_angle_module;
41 static PyObject *const_tuple_str_plain_empty_tuple; 42 static PyObject *const_tuple_str_plain_empty_tuple;
42 static PyObject *const_str_plain_None; 43 static PyObject *const_str_plain_None;
43 static PyObject *const_str_plain_x; 44 static PyObject *const_str_plain_x;
44 static PyObject *const_str_plain_empty; 45 static PyObject *const_str_plain_empty;
n 45 static PyObject *const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd; n
46 extern PyObject *const_str_plain_print; 46 extern PyObject *const_str_plain_print;
n n 47 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
47 extern PyObject *const_str_plain___doc__; 48 extern PyObject *const_str_plain___doc__;
48 extern PyObject *const_str_plain___cached__; 49 extern PyObject *const_str_plain___cached__;
n 49 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple; n
50 extern PyObject *const_tuple_empty; 50 extern PyObject *const_tuple_empty;
n 51 static PyObject *const_str_plain_repeat; n
52 static PyObject *const_int_pos_50000; 51 static PyObject *const_int_pos_50000;
n n 52 extern PyObject *const_int_pos_1;
53 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352; 53 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352;
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 )
61 { 61 {
n n 62     const_str_plain_repeat = UNSTREAM_STRING_ASCII(&constant_bin[ 38 ], 6, 1);
62     const_tuple_none_int_pos_50000_tuple = PyTuple_New(2); 63     const_tuple_none_int_pos_50000_tuple = PyTuple_New(2);
63     PyTuple_SET_ITEM(const_tuple_none_int_pos_50000_tuple, 0, Py_None); Py_INCREF(Py_None); 64     PyTuple_SET_ITEM(const_tuple_none_int_pos_50000_tuple, 0, Py_None); Py_INCREF(Py_None);
64     const_int_pos_50000 = PyLong_FromUnsignedLong(50000ul); 65     const_int_pos_50000 = PyLong_FromUnsignedLong(50000ul);
65     PyTuple_SET_ITEM(const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000); Py_INCREF(const_int_pos_50000); 66     PyTuple_SET_ITEM(const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000); Py_INCREF(const_int_pos_50000);
n 66     const_str_plain_itertools = UNSTREAM_STRING_ASCII(&constant_bin[ 38 ], 9, 1); n 67     const_str_plain_itertools = UNSTREAM_STRING_ASCII(&constant_bin[ 44 ], 9, 1);
67     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII(&constant_bin[ 6 ], 16, 1); 68     const_str_plain_calledRepeatedly = UNSTREAM_STRING_ASCII(&constant_bin[ 6 ], 16, 1);
n 68     const_str_digest_3787adaddea590b1e85379b441a77dfe = UNSTREAM_STRING_ASCII(&constant_bin[ 47 ], 46, 0); n 69     const_str_digest_3787adaddea590b1e85379b441a77dfe = UNSTREAM_STRING_ASCII(&constant_bin[ 53 ], 46, 0);
69     const_str_angle_module = UNSTREAM_STRING_ASCII(&constant_bin[ 93 ], 8, 0); 70     const_str_angle_module = UNSTREAM_STRING_ASCII(&constant_bin[ 99 ], 8, 0);
70     const_tuple_str_plain_empty_tuple = PyTuple_New(1); 71     const_tuple_str_plain_empty_tuple = PyTuple_New(1);
n 71     const_str_plain_empty = UNSTREAM_STRING_ASCII(&constant_bin[ 101 ], 5, 1); n 72     const_str_plain_empty = UNSTREAM_STRING_ASCII(&constant_bin[ 107 ], 5, 1);
72     PyTuple_SET_ITEM(const_tuple_str_plain_empty_tuple, 0, const_str_plain_empty); Py_INCREF(const_str_plain_empty); 73     PyTuple_SET_ITEM(const_tuple_str_plain_empty_tuple, 0, const_str_plain_empty); Py_INCREF(const_str_plain_empty);
n 73     const_str_plain_None = UNSTREAM_STRING_ASCII(&constant_bin[ 106 ], 4, 1); n 74     const_str_plain_None = UNSTREAM_STRING_ASCII(&constant_bin[ 112 ], 4, 1);
74     const_str_plain_x = UNSTREAM_STRING_ASCII(&constant_bin[ 110 ], 1, 1); 75     const_str_plain_x = UNSTREAM_STRING_ASCII(&constant_bin[ 116 ], 1, 1);
75     const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd = UNSTREAM_STRING_ASCII(&constant_bin[ 111 ], 31, 0);
76     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New(1); 76     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New(1);
n 77     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII(&constant_bin[ 142 ], 3, 0); n 77     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII(&constant_bin[ 117 ], 3, 0);
78     PyTuple_SET_ITEM(const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352); Py_INCREF(const_str_digest_5ed1392909ad16e6227b8230f4582352); 78     PyTuple_SET_ITEM(const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352); Py_INCREF(const_str_digest_5ed1392909ad16e6227b8230f4582352);
n 79     const_str_plain_repeat = UNSTREAM_STRING_ASCII(&constant_bin[ 145 ], 6, 1); n
80 79
81     constants_created = true; 80     constants_created = true;
82 } 81 }
83 82
84 /* Function to verify module private constants for non-corruption. */ 83 /* Function to verify module private constants for non-corruption. */
93 #endif 92 #endif
94 93
95 // The module code objects. 94 // The module code objects.
96 static PyCodeObject *codeobj_1b0b5b2850a2aa71b0ca82978762c12b; 95 static PyCodeObject *codeobj_1b0b5b2850a2aa71b0ca82978762c12b;
97 static PyCodeObject *codeobj_631ad396eb5f1873fe79d94ee846ccfa; 96 static PyCodeObject *codeobj_631ad396eb5f1873fe79d94ee846ccfa;
n 98 static PyCodeObject *codeobj_f150b18fdd5e431d1af543acf94356ec; n
99 /* For use in "MainProgram.c". */ 97 /* For use in "MainProgram.c". */
100 PyCodeObject *codeobj_main = NULL; 98 PyCodeObject *codeobj_main = NULL;
101 99
102 static void createModuleCodeObjects(void) 100 static void createModuleCodeObjects(void)
103 { 101 {
104     module_filename_obj = const_str_digest_3787adaddea590b1e85379b441a77dfe; 102     module_filename_obj = const_str_digest_3787adaddea590b1e85379b441a77dfe;
105     codeobj_1b0b5b2850a2aa71b0ca82978762c12b = MAKE_CODEOBJ(module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE); 103     codeobj_1b0b5b2850a2aa71b0ca82978762c12b = MAKE_CODEOBJ(module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE);
106     codeobj_631ad396eb5f1873fe79d94ee846ccfa = MAKE_CODEOBJ(module_filename_obj, const_str_plain_calledRepeatedly, 23, const_tuple_str_plain_empty_tuple, 0, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE); 104     codeobj_631ad396eb5f1873fe79d94ee846ccfa = MAKE_CODEOBJ(module_filename_obj, const_str_plain_calledRepeatedly, 23, const_tuple_str_plain_empty_tuple, 0, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE);
n 107     codeobj_f150b18fdd5e431d1af543acf94356ec = MAKE_CODEOBJ(module_filename_obj, const_str_plain_empty, 26, const_tuple_empty, 0, 0, CO_NOFREE); n
108 } 105 }
109 106
110 // The module function declarations. 107 // The module function declarations.
111 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(); 108 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly();
n 112   n
113  
114 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty();
115 109
116 110
117 // The module function definitions. 111 // The module function definitions.
118 static PyObject *impl___main__$$$function_1_calledRepeatedly(struct Nuitka_FunctionObject const *self, PyObject **python_pars) { 112 static PyObject *impl___main__$$$function_1_calledRepeatedly(struct Nuitka_FunctionObject const *self, PyObject **python_pars) {
119     // Preserve error status for checks 113     // Preserve error status for checks
120 #ifndef __NUITKA_NO_ASSERT__ 114 #ifndef __NUITKA_NO_ASSERT__
121     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 115     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
122 #endif 116 #endif
123 117
124     // Local variable declarations. 118     // Local variable declarations.
n 125     PyObject *var_empty = NULL; n
126     PyObject *tmp_return_value = NULL; 119     PyObject *tmp_return_value = NULL;
127 120
128     // Actual function body. 121     // Actual function body.
n 129     { n 122     tmp_return_value = const_int_pos_1;
130         PyObject *tmp_assign_source_1;
131         tmp_assign_source_1 = MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty();
132  
133  
134  
135         assert(var_empty == NULL);
136         var_empty = tmp_assign_source_1;
137     }
138     // Tried code:
139     CHECK_OBJECT(var_empty);
140     tmp_return_value = var_empty;
141     Py_INCREF(tmp_return_value); 123     Py_INCREF(tmp_return_value);
n 142     goto try_return_handler_1; n
143     // tried codes exits in all cases
144     NUITKA_CANNOT_GET_HERE(__main__$$$function_1_calledRepeatedly);
145     return NULL;
146     // Return handler code:
147     try_return_handler_1:;
148     CHECK_OBJECT((PyObject *)var_empty);
149     Py_DECREF(var_empty);
150     var_empty = NULL;
151  
152     goto function_return_exit; 124     goto function_return_exit;
n 153     // End of try: n
154 125
155     // Return statement must have exited already. 126     // Return statement must have exited already.
156     NUITKA_CANNOT_GET_HERE(__main__$$$function_1_calledRepeatedly); 127     NUITKA_CANNOT_GET_HERE(__main__$$$function_1_calledRepeatedly);
157     return NULL; 128     return NULL;
158 129
176         const_str_plain_calledRepeatedly, 147         const_str_plain_calledRepeatedly,
177 #if PYTHON_VERSION >= 300 148 #if PYTHON_VERSION >= 300
178         NULL, 149         NULL,
179 #endif 150 #endif
180         codeobj_631ad396eb5f1873fe79d94ee846ccfa, 151         codeobj_631ad396eb5f1873fe79d94ee846ccfa,
t 181         NULL, t
182 #if PYTHON_VERSION >= 300
183         NULL,
184         NULL,
185 #endif
186         module___main__,
187         NULL,
188         0
189     );
190  
191     return (PyObject *)result;
192 }
193  
194  
195  
196 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty() {
197     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
198         NULL,
199         const_str_plain_empty,
200 #if PYTHON_VERSION >= 300
201         const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd,
202 #endif
203         codeobj_f150b18fdd5e431d1af543acf94356ec,
204         NULL, 152         NULL,
205 #if PYTHON_VERSION >= 300 153 #if PYTHON_VERSION >= 300
206         NULL, 154         NULL,
207         NULL, 155         NULL,
208 #endif 156 #endif