Construct SetCreation

Performance Diagrams

Construct SetCreation 0010000000100000002000000020000000300000003000000040000000400000005000000050000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)5594122473.61538461538461257.0CPython 2.744703641196.30769230769232306.64102403609024Nuitka (historic)45352340319.0000000000001303.77545386400004Nuitka (master)45302066441.69230769230774303.99753479033365Nuitka (develop)45351374564.3846153846155303.779721083136Nuitka (factory)Construct SetCreationTicks Construct SetCreation 001000000010000000200000002000000030000000300000004000000040000000500000005000000060000000600000007000000070000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)7295837673.61538461538461257.0CPython 3.50196.30769230769232504.11538461538464Nuitka (historic)53492742319.0000000000001322.9315337925327Nuitka (master)53494118441.69230769230774322.92687317934644Nuitka (develop)53399008564.3846153846155323.24901774340265Nuitka (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     int tmp_res;
129     PyObject *tmp_return_value; 126     PyObject *tmp_return_value;
n 130     PyObject *tmp_set_element_1_1; n
131     PyObject *tmp_set_element_2_1;
132     PyObject *tmp_set_element_3_1;
133     PyObject *tmp_set_element_4_1;
134     PyObject *tmp_set_element_5_1;
135     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; 127     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
136     static struct Nuitka_FrameObject *cache_frame_function = NULL; 128     static struct Nuitka_FrameObject *cache_frame_function = NULL;
137 129
138     struct Nuitka_FrameObject *frame_function; 130     struct Nuitka_FrameObject *frame_function;
139 131
140     char const *type_description; 132     char const *type_description;
141     tmp_return_value = NULL; 133     tmp_return_value = NULL;
142 134
143     // Actual function code. 135     // Actual function code.
144     // Tried code: 136     // Tried code:
n 145     MAKE_OR_REUSE_FRAME( cache_frame_function, codeobj_d21ae2d54926bc60714eef34c9bdfa35, module___main__, sizeof(PyObject *) ); n 137     MAKE_OR_REUSE_FRAME( cache_frame_function, codeobj_d21ae2d54926bc60714eef34c9bdfa35, module___main__, sizeof(void *) );
146     frame_function = cache_frame_function; 138     frame_function = cache_frame_function;
147 139
148     // Push the new frame as the currently active one. 140     // Push the new frame as the currently active one.
149     pushFrameStack( frame_function ); 141     pushFrameStack( frame_function );
150 142
168         exception_tb = NULL; 160         exception_tb = NULL;
169         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 161         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
170         CHAIN_EXCEPTION( exception_value ); 162         CHAIN_EXCEPTION( exception_value );
171 163
172         exception_lineno = 24; 164         exception_lineno = 24;
n 173         type_description = "o"; n 165         type_description = "N";
174         goto frame_exception_exit_1; 166         goto frame_exception_exit_1;
175     } 167     }
n 176   n
177     tmp_assign_source_1 = PySet_New( NULL );
178     tmp_set_element_1_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
179  
180     if (unlikely( tmp_set_element_1_1 == NULL ))
181     {
182         tmp_set_element_1_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
183     }
184  
185     if ( tmp_set_element_1_1 == NULL )
186     {
187         Py_DECREF( tmp_assign_source_1 );
188         exception_type = PyExc_NameError;
189         Py_INCREF( exception_type );
190         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
191         exception_tb = NULL;
192         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
193         CHAIN_EXCEPTION( exception_value );
194  
195         exception_lineno = 28;
196         type_description = "o";
197         goto frame_exception_exit_1;
198     }
199  
200     tmp_set_element_2_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
201  
202     if (unlikely( tmp_set_element_2_1 == NULL ))
203     {
204         tmp_set_element_2_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
205     }
206  
207     if ( tmp_set_element_2_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         type_description = "o";
219         goto frame_exception_exit_1;
220     }
221  
222     tmp_set_element_3_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
223  
224     if (unlikely( tmp_set_element_3_1 == NULL ))
225     {
226         tmp_set_element_3_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
227     }
228  
229     if ( tmp_set_element_3_1 == NULL )
230     {
231         Py_DECREF( tmp_assign_source_1 );
232         exception_type = PyExc_NameError;
233         Py_INCREF( exception_type );
234         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
235         exception_tb = NULL;
236         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
237         CHAIN_EXCEPTION( exception_value );
238  
239         exception_lineno = 30;
240         type_description = "o";
241         goto frame_exception_exit_1;
242     }
243  
244     tmp_set_element_4_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_module_value1 );
245  
246     if (unlikely( tmp_set_element_4_1 == NULL ))
247     {
248         tmp_set_element_4_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_module_value1 );
249     }
250  
251     if ( tmp_set_element_4_1 == NULL )
252     {
253         Py_DECREF( tmp_assign_source_1 );
254         exception_type = PyExc_NameError;
255         Py_INCREF( exception_type );
256         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "module_value1" );
257         exception_tb = NULL;
258         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
259         CHAIN_EXCEPTION( exception_value );
260  
261         exception_lineno = 31;
262         type_description = "o";
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         type_description = "o";
285         goto frame_exception_exit_1;
286     }
287  
288     tmp_res = PySet_Add( tmp_assign_source_1, tmp_set_element_5_1 );
289     if ( tmp_res != 0 )
290     {
291         assert( ERROR_OCCURRED() );
292  
293         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
294         Py_DECREF( tmp_assign_source_1 );
295  
296         exception_lineno = 27;
297         type_description = "o";
298         goto frame_exception_exit_1;
299     }
300     tmp_res = PySet_Add( tmp_assign_source_1, tmp_set_element_4_1 );
301     if ( tmp_res != 0 )
302     {
303         assert( ERROR_OCCURRED() );
304  
305         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
306         Py_DECREF( tmp_assign_source_1 );
307  
308         exception_lineno = 27;
309         type_description = "o";
310         goto frame_exception_exit_1;
311     }
312     tmp_res = PySet_Add( tmp_assign_source_1, tmp_set_element_3_1 );
313     if ( tmp_res != 0 )
314     {
315         assert( ERROR_OCCURRED() );
316  
317         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
318         Py_DECREF( tmp_assign_source_1 );
319  
320         exception_lineno = 27;
321         type_description = "o";
322         goto frame_exception_exit_1;
323     }
324     tmp_res = PySet_Add( tmp_assign_source_1, tmp_set_element_2_1 );
325     if ( tmp_res != 0 )
326     {
327         assert( ERROR_OCCURRED() );
328  
329         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
330         Py_DECREF( tmp_assign_source_1 );
331  
332         exception_lineno = 27;
333         type_description = "o";
334         goto frame_exception_exit_1;
335     }
336     tmp_res = PySet_Add( tmp_assign_source_1, tmp_set_element_1_1 );
337     if ( tmp_res != 0 )
338     {
339         assert( ERROR_OCCURRED() );
340  
341         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
342         Py_DECREF( tmp_assign_source_1 );
343  
344         exception_lineno = 27;
345         type_description = "o";
346         goto frame_exception_exit_1;
347     }
348     assert( var_l == NULL );
349     var_l = tmp_assign_source_1;
350 168
351 169
352 #if 0 170 #if 0
353     RESTORE_FRAME_EXCEPTION( frame_function ); 171     RESTORE_FRAME_EXCEPTION( frame_function );
354 #endif 172 #endif
371     else if ( exception_tb->tb_frame != &frame_function->m_frame ) 189     else if ( exception_tb->tb_frame != &frame_function->m_frame )
372     { 190     {
373         exception_tb = ADD_TRACEBACK( exception_tb, frame_function, exception_lineno ); 191         exception_tb = ADD_TRACEBACK( exception_tb, frame_function, exception_lineno );
374     } 192     }
375 193
n 376     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 );
377 195
378     // Release cached frame. 196     // Release cached frame.
379     if ( frame_function == cache_frame_function ) 197     if ( frame_function == cache_frame_function )
380     { 198     {
381         Py_DECREF( frame_function ); 199         Py_DECREF( frame_function );
391     // Return the error. 209     // Return the error.
392     goto try_except_handler_1; 210     goto try_except_handler_1;
393 211
394     frame_no_exception_1:; 212     frame_no_exception_1:;
395 213
n 396     tmp_return_value = var_l; n
397  
398     Py_INCREF( tmp_return_value );
399     goto try_return_handler_1; 214     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: 215     // Exception handler code:
411     try_except_handler_1:; 216     try_except_handler_1:;
412     exception_keeper_type_1 = exception_type; 217     exception_keeper_type_1 = exception_type;
413     exception_keeper_value_1 = exception_value; 218     exception_keeper_value_1 = exception_value;
414     exception_keeper_tb_1 = exception_tb; 219     exception_keeper_tb_1 = exception_tb;
424     exception_tb = exception_keeper_tb_1; 229     exception_tb = exception_keeper_tb_1;
425     exception_lineno = exception_keeper_lineno_1; 230     exception_lineno = exception_keeper_lineno_1;
426 231
427     goto function_exception_exit; 232     goto function_exception_exit;
428     // 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;
429 238
430     // Return statement must have exited already. 239     // Return statement must have exited already.
431     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 240     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
432     return NULL; 241     return NULL;
433 242