Construct SetCreation

Performance Diagrams

Construct SetCreation 0010000000100000002000000020000000300000003000000040000000400000005000000050000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)5594122473.61538461538461257.0CPython 2.744703641196.30769230769232306.64102403609024Nuitka (historic)44902236319.0000000000001305.76374827595146Nuitka (master)45352236441.69230769230774303.7759132747559Nuitka (develop)45352224564.3846153846155303.7759662836893Nuitka (factory)Construct SetCreationTicks Construct SetCreation 001000000010000000200000002000000030000000300000004000000040000000500000005000000060000000600000007000000070000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)7295837673.61538461538461257.0CPython 3.50196.30769230769232504.11538461538464Nuitka (historic)53049528319.0000000000001324.4327322029376Nuitka (master)53505688441.69230769230774322.8876847385292Nuitka (develop)53499618564.3846153846155322.90824427489576Nuitka (factory)Construct SetCreationTicks

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


# construct_end

    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
# 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 # construct_end 37 # construct_end
38 38
39     return l 39     return l
40 40
41 for x in xrange(50000): 41 for x in xrange(50000):

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     int tmp_res; n
130     PyObject *tmp_return_value; 127     PyObject *tmp_return_value;
n 131     PyObject *tmp_set_element_1_1; n
132     PyObject *tmp_set_element_2_1;
133     PyObject *tmp_set_element_3_1;
134     PyObject *tmp_set_element_4_1;
135     PyObject *tmp_set_element_5_1;
136     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; 128     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
137     static PyFrameObject *cache_frame_function = NULL; 129     static PyFrameObject *cache_frame_function = NULL;
138 130
139     PyFrameObject *frame_function; 131     PyFrameObject *frame_function;
140 132
175         CHAIN_EXCEPTION( exception_value ); 167         CHAIN_EXCEPTION( exception_value );
176 168
177         exception_lineno = 24; 169         exception_lineno = 24;
178         goto frame_exception_exit_1; 170         goto frame_exception_exit_1;
179     } 171     }
n 180   n
181     tmp_assign_source_1 = PySet_New( NULL );
182     tmp_set_element_1_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
183  
184     if (unlikely( tmp_set_element_1_1 == NULL ))
185     {
186         tmp_set_element_1_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
187     }
188  
189     if ( tmp_set_element_1_1 == NULL )
190     {
191         Py_DECREF( tmp_assign_source_1 );
192         exception_type = PyExc_NameError;
193         Py_INCREF( exception_type );
194         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
195         exception_tb = NULL;
196         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
197         CHAIN_EXCEPTION( exception_value );
198  
199         exception_lineno = 28;
200         goto frame_exception_exit_1;
201     }
202  
203     tmp_set_element_2_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
204  
205     if (unlikely( tmp_set_element_2_1 == NULL ))
206     {
207         tmp_set_element_2_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
208     }
209  
210     if ( tmp_set_element_2_1 == NULL )
211     {
212         Py_DECREF( tmp_assign_source_1 );
213         exception_type = PyExc_NameError;
214         Py_INCREF( exception_type );
215         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
216         exception_tb = NULL;
217         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
218         CHAIN_EXCEPTION( exception_value );
219  
220         exception_lineno = 29;
221         goto frame_exception_exit_1;
222     }
223  
224     tmp_set_element_3_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
225  
226     if (unlikely( tmp_set_element_3_1 == NULL ))
227     {
228         tmp_set_element_3_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
229     }
230  
231     if ( tmp_set_element_3_1 == NULL )
232     {
233         Py_DECREF( tmp_assign_source_1 );
234         exception_type = PyExc_NameError;
235         Py_INCREF( exception_type );
236         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
237         exception_tb = NULL;
238         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
239         CHAIN_EXCEPTION( exception_value );
240  
241         exception_lineno = 30;
242         goto frame_exception_exit_1;
243     }
244  
245     tmp_set_element_4_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
246  
247     if (unlikely( tmp_set_element_4_1 == NULL ))
248     {
249         tmp_set_element_4_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
250     }
251  
252     if ( tmp_set_element_4_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         goto frame_exception_exit_1;
264     }
265  
266     tmp_set_element_5_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
267  
268     if (unlikely( tmp_set_element_5_1 == NULL ))
269     {
270         tmp_set_element_5_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
271     }
272  
273     if ( tmp_set_element_5_1 == NULL )
274     {
275         Py_DECREF( tmp_assign_source_1 );
276         exception_type = PyExc_NameError;
277         Py_INCREF( exception_type );
278         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
279         exception_tb = NULL;
280         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
281         CHAIN_EXCEPTION( exception_value );
282  
283         exception_lineno = 32;
284         goto frame_exception_exit_1;
285     }
286  
287     tmp_res = PySet_Add( tmp_assign_source_1, tmp_set_element_5_1 );
288     if ( tmp_res != 0 )
289     {
290         assert( ERROR_OCCURRED() );
291  
292         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
293         Py_DECREF( tmp_assign_source_1 );
294  
295         exception_lineno = 27;
296         goto frame_exception_exit_1;
297     }
298     tmp_res = PySet_Add( tmp_assign_source_1, tmp_set_element_4_1 );
299     if ( tmp_res != 0 )
300     {
301         assert( ERROR_OCCURRED() );
302  
303         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
304         Py_DECREF( tmp_assign_source_1 );
305  
306         exception_lineno = 27;
307         goto frame_exception_exit_1;
308     }
309     tmp_res = PySet_Add( tmp_assign_source_1, tmp_set_element_3_1 );
310     if ( tmp_res != 0 )
311     {
312         assert( ERROR_OCCURRED() );
313  
314         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
315         Py_DECREF( tmp_assign_source_1 );
316  
317         exception_lineno = 27;
318         goto frame_exception_exit_1;
319     }
320     tmp_res = PySet_Add( tmp_assign_source_1, tmp_set_element_2_1 );
321     if ( tmp_res != 0 )
322     {
323         assert( ERROR_OCCURRED() );
324  
325         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
326         Py_DECREF( tmp_assign_source_1 );
327  
328         exception_lineno = 27;
329         goto frame_exception_exit_1;
330     }
331     tmp_res = PySet_Add( tmp_assign_source_1, tmp_set_element_1_1 );
332     if ( tmp_res != 0 )
333     {
334         assert( ERROR_OCCURRED() );
335  
336         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
337         Py_DECREF( tmp_assign_source_1 );
338  
339         exception_lineno = 27;
340         goto frame_exception_exit_1;
341     }
342     assert( var_l == NULL );
343     var_l = tmp_assign_source_1;
344 172
345 173
346 #if 0 174 #if 0
347     RESTORE_FRAME_EXCEPTION( frame_function ); 175     RESTORE_FRAME_EXCEPTION( frame_function );
348 #endif 176 #endif
378 206
379         if (needs_detach) 207         if (needs_detach)
380         { 208         {
381 209
382             tmp_frame_locals = PyDict_New(); 210             tmp_frame_locals = PyDict_New();
n 383             if ( var_l ) n
384             {
385                 int res = PyDict_SetItem(
386                     tmp_frame_locals,
387                     const_str_plain_l,
388                     var_l
389                 );
390  
391                 assert( res == 0 );
392             }
393  
394 211
395 212
396             detachFrame( exception_tb, tmp_frame_locals ); 213             detachFrame( exception_tb, tmp_frame_locals );
397         } 214         }
398     } 215     }
407     // Return the error. 224     // Return the error.
408     goto try_except_handler_1; 225     goto try_except_handler_1;
409 226
410     frame_no_exception_1:; 227     frame_no_exception_1:;
411 228
n 412     tmp_return_value = var_l; n
413  
414     Py_INCREF( tmp_return_value );
415     goto try_return_handler_1; 229     goto try_end_1;
416     // tried codes exits in all cases
417     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
418     return NULL;
419     // Return handler code:
420     try_return_handler_1:;
421     CHECK_OBJECT( (PyObject *)var_l );
422     Py_DECREF( var_l );
423     var_l = NULL;
424  
425     goto function_return_exit;
426     // Exception handler code: 230     // Exception handler code:
427     try_except_handler_1:; 231     try_except_handler_1:;
428     exception_keeper_type_1 = exception_type; 232     exception_keeper_type_1 = exception_type;
429     exception_keeper_value_1 = exception_value; 233     exception_keeper_value_1 = exception_value;
430     exception_keeper_tb_1 = exception_tb; 234     exception_keeper_tb_1 = exception_tb;
440     exception_tb = exception_keeper_tb_1; 244     exception_tb = exception_keeper_tb_1;
441     exception_lineno = exception_keeper_lineno_1; 245     exception_lineno = exception_keeper_lineno_1;
442 246
443     goto function_exception_exit; 247     goto function_exception_exit;
444     // 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;
445 253
446     // Return statement must have exited already. 254     // Return statement must have exited already.
447     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 255     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
448     return NULL; 256     return NULL;
449 257