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)33500200441.69230769230774326.814466132298Nuitka (develop)33500380564.3846153846155326.8135134763339Nuitka (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)36601792441.69230769230774337.7227702299916Nuitka (develop)36598797564.3846153846155337.73638557101333Nuitka (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_frame_locals; 126     PyObject *tmp_frame_locals;
n 129     PyObject *tmp_list_element_1; n
130     PyObject *tmp_return_value; 127     PyObject *tmp_return_value;
131     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; 128     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
132     static PyFrameObject *cache_frame_function = NULL; 129     static PyFrameObject *cache_frame_function = NULL;
133 130
134     PyFrameObject *frame_function; 131     PyFrameObject *frame_function;
170         CHAIN_EXCEPTION( exception_value ); 167         CHAIN_EXCEPTION( exception_value );
171 168
172         exception_lineno = 24; 169         exception_lineno = 24;
173         goto frame_exception_exit_1; 170         goto frame_exception_exit_1;
174     } 171     }
n 175   n
176     tmp_assign_source_1 = PyList_New( 5 );
177     tmp_list_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
178  
179     if (unlikely( tmp_list_element_1 == NULL ))
180     {
181         tmp_list_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
182     }
183  
184     if ( tmp_list_element_1 == NULL )
185     {
186         Py_DECREF( tmp_assign_source_1 );
187         exception_type = PyExc_NameError;
188         Py_INCREF( exception_type );
189         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
190         exception_tb = NULL;
191         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
192         CHAIN_EXCEPTION( exception_value );
193  
194         exception_lineno = 28;
195         goto frame_exception_exit_1;
196     }
197  
198     Py_INCREF( tmp_list_element_1 );
199     PyList_SET_ITEM( tmp_assign_source_1, 0, tmp_list_element_1 );
200     tmp_list_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
201  
202     if (unlikely( tmp_list_element_1 == NULL ))
203     {
204         tmp_list_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
205     }
206  
207     if ( tmp_list_element_1 == NULL )
208     {
209         Py_DECREF( tmp_assign_source_1 );
210         exception_type = PyExc_NameError;
211         Py_INCREF( exception_type );
212         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
213         exception_tb = NULL;
214         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
215         CHAIN_EXCEPTION( exception_value );
216  
217         exception_lineno = 29;
218         goto frame_exception_exit_1;
219     }
220  
221     Py_INCREF( tmp_list_element_1 );
222     PyList_SET_ITEM( tmp_assign_source_1, 1, tmp_list_element_1 );
223     tmp_list_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
224  
225     if (unlikely( tmp_list_element_1 == NULL ))
226     {
227         tmp_list_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
228     }
229  
230     if ( tmp_list_element_1 == NULL )
231     {
232         Py_DECREF( tmp_assign_source_1 );
233         exception_type = PyExc_NameError;
234         Py_INCREF( exception_type );
235         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
236         exception_tb = NULL;
237         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
238         CHAIN_EXCEPTION( exception_value );
239  
240         exception_lineno = 30;
241         goto frame_exception_exit_1;
242     }
243  
244     Py_INCREF( tmp_list_element_1 );
245     PyList_SET_ITEM( tmp_assign_source_1, 2, tmp_list_element_1 );
246     tmp_list_element_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
247  
248     if (unlikely( tmp_list_element_1 == NULL ))
249     {
250         tmp_list_element_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
251     }
252  
253     if ( tmp_list_element_1 == NULL )
254     {
255         Py_DECREF( tmp_assign_source_1 );
256         exception_type = PyExc_NameError;
257         Py_INCREF( exception_type );
258         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
259         exception_tb = NULL;
260         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
261         CHAIN_EXCEPTION( exception_value );
262  
263         exception_lineno = 31;
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         goto frame_exception_exit_1;
288     }
289  
290     Py_INCREF( tmp_list_element_1 );
291     PyList_SET_ITEM( tmp_assign_source_1, 4, tmp_list_element_1 );
292     assert( var_l == NULL );
293     var_l = tmp_assign_source_1;
294 172
295 173
296 #if 0 174 #if 0
297     RESTORE_FRAME_EXCEPTION( frame_function ); 175     RESTORE_FRAME_EXCEPTION( frame_function );
298 #endif 176 #endif
328 206
329         if (needs_detach) 207         if (needs_detach)
330         { 208         {
331 209
332             tmp_frame_locals = PyDict_New(); 210             tmp_frame_locals = PyDict_New();
n 333             if ( var_l ) n
334             {
335                 int res = PyDict_SetItem(
336                     tmp_frame_locals,
337                     const_str_plain_l,
338                     var_l
339                 );
340  
341                 assert( res == 0 );
342             }
343  
344 211
345 212
346             detachFrame( exception_tb, tmp_frame_locals ); 213             detachFrame( exception_tb, tmp_frame_locals );
347         } 214         }
348     } 215     }
357     // Return the error. 224     // Return the error.
358     goto try_except_handler_1; 225     goto try_except_handler_1;
359 226
360     frame_no_exception_1:; 227     frame_no_exception_1:;
361 228
n 362     tmp_return_value = var_l; n
363  
364     Py_INCREF( tmp_return_value );
365     goto try_return_handler_1; 229     goto try_end_1;
366     // tried codes exits in all cases
367     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
368     return NULL;
369     // Return handler code:
370     try_return_handler_1:;
371     CHECK_OBJECT( (PyObject *)var_l );
372     Py_DECREF( var_l );
373     var_l = NULL;
374  
375     goto function_return_exit;
376     // Exception handler code: 230     // Exception handler code:
377     try_except_handler_1:; 231     try_except_handler_1:;
378     exception_keeper_type_1 = exception_type; 232     exception_keeper_type_1 = exception_type;
379     exception_keeper_value_1 = exception_value; 233     exception_keeper_value_1 = exception_value;
380     exception_keeper_tb_1 = exception_tb; 234     exception_keeper_tb_1 = exception_tb;
390     exception_tb = exception_keeper_tb_1; 244     exception_tb = exception_keeper_tb_1;
391     exception_lineno = exception_keeper_lineno_1; 245     exception_lineno = exception_keeper_lineno_1;
392 246
393     goto function_exception_exit; 247     goto function_exception_exit;
394     // End of try: 248     // End of try:
t t 249     try_end_1:;
250     tmp_return_value = const_int_pos_1;
251     Py_INCREF( tmp_return_value );
252     goto function_return_exit;
395 253
396     // Return statement must have exited already. 254     // Return statement must have exited already.
397     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 255     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
398     return NULL; 256     return NULL;
399 257