Construct SetCreation

Performance Diagrams

Construct SetCreation 0010000000100000002000000020000000300000003000000040000000400000005000000050000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)5594122473.61538461538461257.0CPython 2.744703641196.30769230769232306.64102403609024Nuitka (historic)45352222319.0000000000001303.7759751185115Nuitka (master)45351724441.69230769230774303.77817498924617Nuitka (develop)45351616564.3846153846155303.77865206964645Nuitka (factory)Construct SetCreationTicks Construct SetCreation 001000000010000000200000002000000030000000300000004000000040000000500000005000000060000000600000007000000070000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)7295837673.61538461538461257.0CPython 3.50196.30769230769232504.11538461538464Nuitka (historic)53394840319.0000000000001323.2631350659028Nuitka (master)53400689441.69230769230774323.2433240727878Nuitka (develop)53401419564.3846153846155323.24085150910616Nuitka (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
113 #ifndef __NUITKA_NO_ASSERT__ 113 #ifndef __NUITKA_NO_ASSERT__
114     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 114     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
115 #endif 115 #endif
116 116
117     // Local variable declarations. 117     // Local variable declarations.
n 118     PyObject *var_l = NULL; n
119     PyObject *exception_type = NULL, *exception_value = NULL; 118     PyObject *exception_type = NULL, *exception_value = NULL;
120     PyTracebackObject *exception_tb = NULL; 119     PyTracebackObject *exception_tb = NULL;
121     NUITKA_MAY_BE_UNUSED int exception_lineno = -1; 120     NUITKA_MAY_BE_UNUSED int exception_lineno = -1;
122     PyObject *exception_keeper_type_1; 121     PyObject *exception_keeper_type_1;
123     PyObject *exception_keeper_value_1; 122     PyObject *exception_keeper_value_1;
124     PyTracebackObject *exception_keeper_tb_1; 123     PyTracebackObject *exception_keeper_tb_1;
125     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 124     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
n 126     PyObject *tmp_assign_source_1; n
127     int tmp_res;
128     PyObject *tmp_return_value; 125     PyObject *tmp_return_value;
n 129     PyObject *tmp_set_element_1_1; n
130     PyObject *tmp_set_element_2_1;
131     PyObject *tmp_set_element_3_1;
132     PyObject *tmp_set_element_4_1;
133     PyObject *tmp_set_element_5_1;
134     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; 126     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
135     static struct Nuitka_FrameObject *cache_frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a = NULL; 127     static struct Nuitka_FrameObject *cache_frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a = NULL;
136 128
137     struct Nuitka_FrameObject *frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a; 129     struct Nuitka_FrameObject *frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a;
138 130
139     char const *type_description; 131     char const *type_description;
140     tmp_return_value = NULL; 132     tmp_return_value = NULL;
141 133
142     // Actual function code. 134     // Actual function code.
143     // Tried code: 135     // Tried code:
n 144     MAKE_OR_REUSE_FRAME( cache_frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a, codeobj_f9a67794e8d0a2f2e64b3e86f9d9fe8a, module___main__, sizeof(PyObject *) ); n 136     MAKE_OR_REUSE_FRAME( cache_frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a, codeobj_f9a67794e8d0a2f2e64b3e86f9d9fe8a, module___main__, sizeof(void *) );
145     frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a = cache_frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a; 137     frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a = cache_frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a;
146 138
147     // Push the new frame as the currently active one. 139     // Push the new frame as the currently active one.
148     pushFrameStack( frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a ); 140     pushFrameStack( frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a );
149 141
167         exception_tb = NULL; 159         exception_tb = NULL;
168         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 160         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
169         CHAIN_EXCEPTION( exception_value ); 161         CHAIN_EXCEPTION( exception_value );
170 162
171         exception_lineno = 24; 163         exception_lineno = 24;
n 172         type_description = "o"; n 164         type_description = "N";
173         goto frame_exception_exit_1; 165         goto frame_exception_exit_1;
174     } 166     }
n 175   n
176     tmp_assign_source_1 = PySet_New( NULL );
177     tmp_set_element_1_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
178  
179     if (unlikely( tmp_set_element_1_1 == NULL ))
180     {
181         tmp_set_element_1_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
182     }
183  
184     if ( tmp_set_element_1_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         type_description = "o";
196         goto frame_exception_exit_1;
197     }
198  
199     tmp_set_element_2_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
200  
201     if (unlikely( tmp_set_element_2_1 == NULL ))
202     {
203         tmp_set_element_2_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
204     }
205  
206     if ( tmp_set_element_2_1 == NULL )
207     {
208         Py_DECREF( tmp_assign_source_1 );
209         exception_type = PyExc_NameError;
210         Py_INCREF( exception_type );
211         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
212         exception_tb = NULL;
213         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
214         CHAIN_EXCEPTION( exception_value );
215  
216         exception_lineno = 29;
217         type_description = "o";
218         goto frame_exception_exit_1;
219     }
220  
221     tmp_set_element_3_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
222  
223     if (unlikely( tmp_set_element_3_1 == NULL ))
224     {
225         tmp_set_element_3_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
226     }
227  
228     if ( tmp_set_element_3_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     tmp_set_element_4_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
244  
245     if (unlikely( tmp_set_element_4_1 == NULL ))
246     {
247         tmp_set_element_4_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
248     }
249  
250     if ( tmp_set_element_4_1 == NULL )
251     {
252         Py_DECREF( tmp_assign_source_1 );
253         exception_type = PyExc_NameError;
254         Py_INCREF( exception_type );
255         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
256         exception_tb = NULL;
257         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
258         CHAIN_EXCEPTION( exception_value );
259  
260         exception_lineno = 31;
261         type_description = "o";
262         goto frame_exception_exit_1;
263     }
264  
265     tmp_set_element_5_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
266  
267     if (unlikely( tmp_set_element_5_1 == NULL ))
268     {
269         tmp_set_element_5_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
270     }
271  
272     if ( tmp_set_element_5_1 == NULL )
273     {
274         Py_DECREF( tmp_assign_source_1 );
275         exception_type = PyExc_NameError;
276         Py_INCREF( exception_type );
277         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
278         exception_tb = NULL;
279         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
280         CHAIN_EXCEPTION( exception_value );
281  
282         exception_lineno = 32;
283         type_description = "o";
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         type_description = "o";
297         goto frame_exception_exit_1;
298     }
299     tmp_res = PySet_Add( tmp_assign_source_1, tmp_set_element_4_1 );
300     if ( tmp_res != 0 )
301     {
302         assert( ERROR_OCCURRED() );
303  
304         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
305         Py_DECREF( tmp_assign_source_1 );
306  
307         exception_lineno = 27;
308         type_description = "o";
309         goto frame_exception_exit_1;
310     }
311     tmp_res = PySet_Add( tmp_assign_source_1, tmp_set_element_3_1 );
312     if ( tmp_res != 0 )
313     {
314         assert( ERROR_OCCURRED() );
315  
316         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
317         Py_DECREF( tmp_assign_source_1 );
318  
319         exception_lineno = 27;
320         type_description = "o";
321         goto frame_exception_exit_1;
322     }
323     tmp_res = PySet_Add( tmp_assign_source_1, tmp_set_element_2_1 );
324     if ( tmp_res != 0 )
325     {
326         assert( ERROR_OCCURRED() );
327  
328         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
329         Py_DECREF( tmp_assign_source_1 );
330  
331         exception_lineno = 27;
332         type_description = "o";
333         goto frame_exception_exit_1;
334     }
335     tmp_res = PySet_Add( tmp_assign_source_1, tmp_set_element_1_1 );
336     if ( tmp_res != 0 )
337     {
338         assert( ERROR_OCCURRED() );
339  
340         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
341         Py_DECREF( tmp_assign_source_1 );
342  
343         exception_lineno = 27;
344         type_description = "o";
345         goto frame_exception_exit_1;
346     }
347     assert( var_l == NULL );
348     var_l = tmp_assign_source_1;
349 167
350 168
351 #if 0 169 #if 0
352     RESTORE_FRAME_EXCEPTION( frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a ); 170     RESTORE_FRAME_EXCEPTION( frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a );
353 #endif 171 #endif
370     else if ( exception_tb->tb_frame != &frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a->m_frame ) 188     else if ( exception_tb->tb_frame != &frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a->m_frame )
371     { 189     {
372         exception_tb = ADD_TRACEBACK( exception_tb, frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a, exception_lineno ); 190         exception_tb = ADD_TRACEBACK( exception_tb, frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a, exception_lineno );
373     } 191     }
374 192
n 375     Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a, type_description ,var_l ); n 193     Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a, type_description ,NULL );
376 194
377     // Release cached frame. 195     // Release cached frame.
378     if ( frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a == cache_frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a ) 196     if ( frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a == cache_frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a )
379     { 197     {
380         Py_DECREF( frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a ); 198         Py_DECREF( frame_f9a67794e8d0a2f2e64b3e86f9d9fe8a );
390     // Return the error. 208     // Return the error.
391     goto try_except_handler_1; 209     goto try_except_handler_1;
392 210
393     frame_no_exception_1:; 211     frame_no_exception_1:;
394 212
n 395     tmp_return_value = var_l; n
396  
397     CHECK_OBJECT( tmp_return_value );
398     Py_INCREF( tmp_return_value );
399     goto try_return_handler_1; 213     goto try_end_1;
400     // tried codes exits in all cases
401     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
402     return NULL;
403     // Return handler code:
404     try_return_handler_1:;
405     CHECK_OBJECT( (PyObject *)var_l );
406     Py_DECREF( var_l );
407     var_l = NULL;
408  
409     goto function_return_exit;
410     // Exception handler code: 214     // Exception handler code:
411     try_except_handler_1:; 215     try_except_handler_1:;
412     exception_keeper_type_1 = exception_type; 216     exception_keeper_type_1 = exception_type;
413     exception_keeper_value_1 = exception_value; 217     exception_keeper_value_1 = exception_value;
414     exception_keeper_tb_1 = exception_tb; 218     exception_keeper_tb_1 = exception_tb;
424     exception_tb = exception_keeper_tb_1; 228     exception_tb = exception_keeper_tb_1;
425     exception_lineno = exception_keeper_lineno_1; 229     exception_lineno = exception_keeper_lineno_1;
426 230
427     goto function_exception_exit; 231     goto function_exception_exit;
428     // End of try: 232     // End of try:
t t 233     try_end_1:;
234     tmp_return_value = const_int_pos_1;
235     Py_INCREF( tmp_return_value );
236     goto function_return_exit;
429 237
430     // Return statement must have exited already. 238     // Return statement must have exited already.
431     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 239     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
432     return NULL; 240     return NULL;
433 241