Construct ListCreation

Performance Diagrams

Construct ListCreation 001000000010000000200000002000000030000000300000004000000040000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)4669132573.61538461538461257.0CPython 2.733751014196.30769230769232325.4870247269207Nuitka (historic)33502006319.0000000000001326.80490781745857Nuitka (master)33500320441.69230769230774326.81383102832194Nuitka (develop)33451841564.3846153846155327.0704077421069Nuitka (factory)Construct ListCreationTicks Construct ListCreation 0010000000100000002000000020000000300000003000000040000000400000005000000050000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)5435857873.61538461538461257.0CPython 3.50196.30769230769232504.11538461538464Nuitka (historic)36606825319.0000000000001337.699890092642Nuitka (master)36597512441.69230769230774337.74222721148504Nuitka (develop)36596723564.3846153846155337.74581402419494Nuitka (factory)Construct ListCreationTicks

Source Code with Construct

module_value1 = 1000

def calledRepeatedly():
    # Force frame and eliminate forward propagation (currently).
    module_value1

# construct_begin
    l = [
        module_value1,
        module_value1,
        module_value1,
        module_value1,
        module_value1
    ]
# construct_alternative



    return l

for x in xrange(50000):
    calledRepeatedly()

print("OK.")

Source Code without Construct

module_value1 = 1000

def calledRepeatedly():
    # Force frame and eliminate forward propagation (currently).
    module_value1

# construct_begin







# construct_alternative
    l = 1
# construct_end

    return l

for x in xrange(50000):
    calledRepeatedly()

print("OK.")

Context Diff of Source Code


Construct
Baseline
22 def calledRepeatedly(): 22 def calledRepeatedly():
23     # Force frame and eliminate forward propagation (currently). 23     # Force frame and eliminate forward propagation (currently).
24     module_value1 24     module_value1
25 25
26 # construct_begin 26 # construct_begin
n 27     l = [ n
28         module_value1,
29         module_value1,
30         module_value1,
31         module_value1,
32         module_value1
33     ]
34 # construct_alternative
35 27
36 28
t t 29  
30  
31  
32  
33  
34 # construct_alternative
35     l = 1
36 # construct_end
37 37
38     return l 38     return l
39 39
40 for x in xrange(50000): 40 for x in xrange(50000):
41     calledRepeatedly() 41     calledRepeatedly()

Context Diff of Generated Code


Construct
Baseline
114 #ifndef __NUITKA_NO_ASSERT__ 114 #ifndef __NUITKA_NO_ASSERT__
115     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 115     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
116 #endif 116 #endif
117 117
118     // Local variable declarations. 118     // Local variable declarations.
n 119     PyObject *var_l = NULL; n
120     PyObject *exception_type = NULL, *exception_value = NULL; 119     PyObject *exception_type = NULL, *exception_value = NULL;
121     PyTracebackObject *exception_tb = NULL; 120     PyTracebackObject *exception_tb = NULL;
122     NUITKA_MAY_BE_UNUSED int exception_lineno = -1; 121     NUITKA_MAY_BE_UNUSED int exception_lineno = -1;
123     PyObject *exception_keeper_type_1; 122     PyObject *exception_keeper_type_1;
124     PyObject *exception_keeper_value_1; 123     PyObject *exception_keeper_value_1;
125     PyTracebackObject *exception_keeper_tb_1; 124     PyTracebackObject *exception_keeper_tb_1;
126     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 125     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
n 127     PyObject *tmp_assign_source_1; n
128     PyObject *tmp_list_element_1;
129     PyObject *tmp_return_value; 126     PyObject *tmp_return_value;
130     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; 127     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
131     static struct Nuitka_FrameObject *cache_frame_function = NULL; 128     static struct Nuitka_FrameObject *cache_frame_function = NULL;
132 129
133     struct Nuitka_FrameObject *frame_function; 130     struct Nuitka_FrameObject *frame_function;
135     char const *type_description; 132     char const *type_description;
136     tmp_return_value = NULL; 133     tmp_return_value = NULL;
137 134
138     // Actual function code. 135     // Actual function code.
139     // Tried code: 136     // Tried code:
n 140     MAKE_OR_REUSE_FRAME( cache_frame_function, codeobj_0114ff034d9330e4e575ff7afd47be78, module___main__, sizeof(PyObject *) ); n 137     MAKE_OR_REUSE_FRAME( cache_frame_function, codeobj_0114ff034d9330e4e575ff7afd47be78, module___main__, sizeof(void *) );
141     frame_function = cache_frame_function; 138     frame_function = cache_frame_function;
142 139
143     // Push the new frame as the currently active one. 140     // Push the new frame as the currently active one.
144     pushFrameStack( frame_function ); 141     pushFrameStack( frame_function );
145 142
163         exception_tb = NULL; 160         exception_tb = NULL;
164         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 161         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
165         CHAIN_EXCEPTION( exception_value ); 162         CHAIN_EXCEPTION( exception_value );
166 163
167         exception_lineno = 24; 164         exception_lineno = 24;
n 168         type_description = "o"; n 165         type_description = "N";
169         goto frame_exception_exit_1; 166         goto frame_exception_exit_1;
170     } 167     }
n 171   n
172     tmp_assign_source_1 = PyList_New( 5 );
173     tmp_list_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
174  
175     if (unlikely( tmp_list_element_1 == NULL ))
176     {
177         tmp_list_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
178     }
179  
180     if ( tmp_list_element_1 == NULL )
181     {
182         Py_DECREF( tmp_assign_source_1 );
183         exception_type = PyExc_NameError;
184         Py_INCREF( exception_type );
185         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
186         exception_tb = NULL;
187         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
188         CHAIN_EXCEPTION( exception_value );
189  
190         exception_lineno = 28;
191         type_description = "o";
192         goto frame_exception_exit_1;
193     }
194  
195     Py_INCREF( tmp_list_element_1 );
196     PyList_SET_ITEM( tmp_assign_source_1, 0, tmp_list_element_1 );
197     tmp_list_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
198  
199     if (unlikely( tmp_list_element_1 == NULL ))
200     {
201         tmp_list_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
202     }
203  
204     if ( tmp_list_element_1 == NULL )
205     {
206         Py_DECREF( tmp_assign_source_1 );
207         exception_type = PyExc_NameError;
208         Py_INCREF( exception_type );
209         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
210         exception_tb = NULL;
211         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
212         CHAIN_EXCEPTION( exception_value );
213  
214         exception_lineno = 29;
215         type_description = "o";
216         goto frame_exception_exit_1;
217     }
218  
219     Py_INCREF( tmp_list_element_1 );
220     PyList_SET_ITEM( tmp_assign_source_1, 1, tmp_list_element_1 );
221     tmp_list_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
222  
223     if (unlikely( tmp_list_element_1 == NULL ))
224     {
225         tmp_list_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
226     }
227  
228     if ( tmp_list_element_1 == NULL )
229     {
230         Py_DECREF( tmp_assign_source_1 );
231         exception_type = PyExc_NameError;
232         Py_INCREF( exception_type );
233         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
234         exception_tb = NULL;
235         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
236         CHAIN_EXCEPTION( exception_value );
237  
238         exception_lineno = 30;
239         type_description = "o";
240         goto frame_exception_exit_1;
241     }
242  
243     Py_INCREF( tmp_list_element_1 );
244     PyList_SET_ITEM( tmp_assign_source_1, 2, tmp_list_element_1 );
245     tmp_list_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
246  
247     if (unlikely( tmp_list_element_1 == NULL ))
248     {
249         tmp_list_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
250     }
251  
252     if ( tmp_list_element_1 == NULL )
253     {
254         Py_DECREF( tmp_assign_source_1 );
255         exception_type = PyExc_NameError;
256         Py_INCREF( exception_type );
257         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
258         exception_tb = NULL;
259         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
260         CHAIN_EXCEPTION( exception_value );
261  
262         exception_lineno = 31;
263         type_description = "o";
264         goto frame_exception_exit_1;
265     }
266  
267     Py_INCREF( tmp_list_element_1 );
268     PyList_SET_ITEM( tmp_assign_source_1, 3, tmp_list_element_1 );
269     tmp_list_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
270  
271     if (unlikely( tmp_list_element_1 == NULL ))
272     {
273         tmp_list_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
274     }
275  
276     if ( tmp_list_element_1 == NULL )
277     {
278         Py_DECREF( tmp_assign_source_1 );
279         exception_type = PyExc_NameError;
280         Py_INCREF( exception_type );
281         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
282         exception_tb = NULL;
283         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
284         CHAIN_EXCEPTION( exception_value );
285  
286         exception_lineno = 32;
287         type_description = "o";
288         goto frame_exception_exit_1;
289     }
290  
291     Py_INCREF( tmp_list_element_1 );
292     PyList_SET_ITEM( tmp_assign_source_1, 4, tmp_list_element_1 );
293     assert( var_l == NULL );
294     var_l = tmp_assign_source_1;
295 168
296 169
297 #if 0 170 #if 0
298     RESTORE_FRAME_EXCEPTION( frame_function ); 171     RESTORE_FRAME_EXCEPTION( frame_function );
299 #endif 172 #endif
316     else if ( exception_tb->tb_frame != &frame_function->m_frame ) 189     else if ( exception_tb->tb_frame != &frame_function->m_frame )
317     { 190     {
318         exception_tb = ADD_TRACEBACK( exception_tb, frame_function, exception_lineno ); 191         exception_tb = ADD_TRACEBACK( exception_tb, frame_function, exception_lineno );
319     } 192     }
320 193
n 321     Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)frame_function, type_description ,var_l ); n 194     Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)frame_function, type_description ,NULL );
322 195
323     // Release cached frame. 196     // Release cached frame.
324     if ( frame_function == cache_frame_function ) 197     if ( frame_function == cache_frame_function )
325     { 198     {
326         Py_DECREF( frame_function ); 199         Py_DECREF( frame_function );
336     // Return the error. 209     // Return the error.
337     goto try_except_handler_1; 210     goto try_except_handler_1;
338 211
339     frame_no_exception_1:; 212     frame_no_exception_1:;
340 213
n 341     tmp_return_value = var_l; n
342  
343     Py_INCREF( tmp_return_value );
344     goto try_return_handler_1; 214     goto try_end_1;
345     // tried codes exits in all cases
346     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
347     return NULL;
348     // Return handler code:
349     try_return_handler_1:;
350     CHECK_OBJECT( (PyObject *)var_l );
351     Py_DECREF( var_l );
352     var_l = NULL;
353  
354     goto function_return_exit;
355     // Exception handler code: 215     // Exception handler code:
356     try_except_handler_1:; 216     try_except_handler_1:;
357     exception_keeper_type_1 = exception_type; 217     exception_keeper_type_1 = exception_type;
358     exception_keeper_value_1 = exception_value; 218     exception_keeper_value_1 = exception_value;
359     exception_keeper_tb_1 = exception_tb; 219     exception_keeper_tb_1 = exception_tb;
369     exception_tb = exception_keeper_tb_1; 229     exception_tb = exception_keeper_tb_1;
370     exception_lineno = exception_keeper_lineno_1; 230     exception_lineno = exception_keeper_lineno_1;
371 231
372     goto function_exception_exit; 232     goto function_exception_exit;
373     // End of try: 233     // End of try:
t t 234     try_end_1:;
235     tmp_return_value = const_int_pos_1;
236     Py_INCREF( tmp_return_value );
237     goto function_return_exit;
374 238
375     // Return statement must have exited already. 239     // Return statement must have exited already.
376     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 240     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
377     return NULL; 241     return NULL;
378 242