Construct CallCompiledFunctionPosArgsDefaults

Performance Diagrams

Construct CallCompiledFunctionPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)19153276188.11538461538461257.0CPython 2.763850281240.03846153846155421.7358132839016Nuitka (master)63850294391.96153846153845421.7357965113141Nuitka (develop)63850294543.8846153846154421.7357965113141Nuitka (factory)Construct CallCompiledFunctionPosArgsDefaultsTicks Construct CallCompiledFunctionPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)19954427888.11538461538461257.0CPython 3.573640405240.03846153846155412.9191990509572Nuitka (master)73646860391.96153846153845412.9112051870204Nuitka (develop)73646994543.8846153846154412.9110392415878Nuitka (factory)Construct CallCompiledFunctionPosArgsDefaultsTicks

Source Code with Construct

from __future__ import print_function

def compiled_func(a = 1,b = 2,c = 3,d = 4,e = 5,f = 6):
    return a, b, c, d, e, f

def calledRepeatedly():
    # This is supposed to make a call to a non-compiled function, which is
    # being optimized separately.
# construct_begin
    compiled_func()
    compiled_func()
    compiled_func()
# construct_alternative



import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Source Code without Construct

from __future__ import print_function

def compiled_func(a = 1,b = 2,c = 3,d = 4,e = 5,f = 6):
    return a, b, c, d, e, f

def calledRepeatedly():
    # This is supposed to make a call to a non-compiled function, which is
    # being optimized separately.
# construct_begin



# construct_alternative
    pass
# construct_end

import itertools
for x in itertools.repeat(None, 50000):
    calledRepeatedly()

print("OK.")

Context Diff of Source Code


Construct
Baseline
24 24
25 def calledRepeatedly(): 25 def calledRepeatedly():
26     # This is supposed to make a call to a non-compiled function, which is 26     # This is supposed to make a call to a non-compiled function, which is
27     # being optimized separately. 27     # being optimized separately.
28 # construct_begin 28 # construct_begin
n 29     compiled_func() n
30     compiled_func()
31     compiled_func()
32 # construct_alternative
33 29
34 30
t t 31  
32 # construct_alternative
33     pass
34 # construct_end
35 35
36 import itertools 36 import itertools
37 for x in itertools.repeat(None, 50000): 37 for x in itertools.repeat(None, 50000):
38     calledRepeatedly() 38     calledRepeatedly()
39 39

Context Diff of Generated Code


Construct
Baseline
130 } 130 }
131 #endif 131 #endif
132 132
133 // The module code objects. 133 // The module code objects.
134 static PyCodeObject *codeobj_101c854ebe2e5246fcffdd430cc5d366; 134 static PyCodeObject *codeobj_101c854ebe2e5246fcffdd430cc5d366;
n 135 static PyCodeObject *codeobj_28de6027e6fa7762740724bc2b706691; n 135 static PyCodeObject *codeobj_1a85ae15eb74d911679d9bd4182bd2d7;
136 static PyCodeObject *codeobj_a14f14d5189ae31e1cda762fffde0ced; 136 static PyCodeObject *codeobj_a14f14d5189ae31e1cda762fffde0ced;
137 /* For use in "MainProgram.c". */ 137 /* For use in "MainProgram.c". */
138 PyCodeObject *codeobj_main = NULL; 138 PyCodeObject *codeobj_main = NULL;
139 139
140 static void createModuleCodeObjects(void) 140 static void createModuleCodeObjects(void)
141 { 141 {
142     module_filename_obj = const_str_digest_72e74dbe017e98d015dc8d7c67664359; 142     module_filename_obj = const_str_digest_72e74dbe017e98d015dc8d7c67664359;
143     codeobj_101c854ebe2e5246fcffdd430cc5d366 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE ); 143     codeobj_101c854ebe2e5246fcffdd430cc5d366 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE );
144     codeobj_main = codeobj_101c854ebe2e5246fcffdd430cc5d366; 144     codeobj_main = codeobj_101c854ebe2e5246fcffdd430cc5d366;
n 145     codeobj_28de6027e6fa7762740724bc2b706691 = MAKE_CODEOBJ( module_filename_obj, const_str_plain_calledRepeatedly, 25, const_tuple_empty, 0, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE ); n 145     codeobj_1a85ae15eb74d911679d9bd4182bd2d7 = MAKE_CODEOBJ( module_filename_obj, const_str_plain_calledRepeatedly, 25, const_tuple_empty, 0, 0, CO_NOFREE );
146     codeobj_a14f14d5189ae31e1cda762fffde0ced = MAKE_CODEOBJ( module_filename_obj, const_str_plain_compiled_func, 22, const_tuple_d4571c3ff966778a8b3ba4a6bd66fdef_tuple, 6, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE ); 146     codeobj_a14f14d5189ae31e1cda762fffde0ced = MAKE_CODEOBJ( module_filename_obj, const_str_plain_compiled_func, 22, const_tuple_d4571c3ff966778a8b3ba4a6bd66fdef_tuple, 6, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE );
147 } 147 }
148 148
149 // The module function declarations. 149 // The module function declarations.
150 static PyObject *MAKE_FUNCTION___main__$$$function_1_compiled_func( PyObject *defaults ); 150 static PyObject *MAKE_FUNCTION___main__$$$function_1_compiled_func( PyObject *defaults );
252 #ifndef __NUITKA_NO_ASSERT__ 252 #ifndef __NUITKA_NO_ASSERT__
253     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 253     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
254 #endif 254 #endif
255 255
256     // Local variable declarations. 256     // Local variable declarations.
n 257     PyObject *exception_type = NULL; n
258     PyObject *exception_value = NULL;
259     PyTracebackObject *exception_tb = NULL;
260     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
261     PyObject *tmp_called_name_1;
262     PyObject *tmp_called_name_2;
263     PyObject *tmp_called_name_3;
264     PyObject *tmp_return_value; 257     PyObject *tmp_return_value;
n 265     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
266     static struct Nuitka_FrameObject *cache_frame_28de6027e6fa7762740724bc2b706691 = NULL;
267  
268     struct Nuitka_FrameObject *frame_28de6027e6fa7762740724bc2b706691;
269  
270     tmp_return_value = NULL; 258     tmp_return_value = NULL;
271 259
272     // Actual function code. 260     // Actual function code.
n 273     MAKE_OR_REUSE_FRAME( cache_frame_28de6027e6fa7762740724bc2b706691, codeobj_28de6027e6fa7762740724bc2b706691, module___main__, 0 ); n
274     frame_28de6027e6fa7762740724bc2b706691 = cache_frame_28de6027e6fa7762740724bc2b706691;
275  
276     // Push the new frame as the currently active one.
277     pushFrameStack( frame_28de6027e6fa7762740724bc2b706691 );
278  
279     // Mark the frame object as in use, ref count 1 will be up for reuse.
280     assert( Py_REFCNT( frame_28de6027e6fa7762740724bc2b706691 ) == 2 ); // Frame stack
281  
282     // Framed code:
283     tmp_called_name_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_compiled_func );
284  
285     if (unlikely( tmp_called_name_1 == NULL ))
286     {
287         tmp_called_name_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_compiled_func );
288     }
289  
290     if ( tmp_called_name_1 == NULL )
291     {
292  
293         exception_type = PyExc_NameError;
294         Py_INCREF( exception_type );
295         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "compiled_func" );
296         exception_tb = NULL;
297         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
298         CHAIN_EXCEPTION( exception_value );
299  
300         exception_lineno = 29;
301  
302         goto frame_exception_exit_1;
303     }
304  
305     frame_28de6027e6fa7762740724bc2b706691->m_frame.f_lineno = 29;
306     tmp_unused = CALL_FUNCTION_NO_ARGS( tmp_called_name_1 );
307     if ( tmp_unused == NULL )
308     {
309         assert( ERROR_OCCURRED() );
310  
311         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
312  
313  
314         exception_lineno = 29;
315  
316         goto frame_exception_exit_1;
317     }
318     Py_DECREF( tmp_unused );
319     tmp_called_name_2 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_compiled_func );
320  
321     if (unlikely( tmp_called_name_2 == NULL ))
322     {
323         tmp_called_name_2 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_compiled_func );
324     }
325  
326     if ( tmp_called_name_2 == NULL )
327     {
328  
329         exception_type = PyExc_NameError;
330         Py_INCREF( exception_type );
331         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "compiled_func" );
332         exception_tb = NULL;
333         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
334         CHAIN_EXCEPTION( exception_value );
335  
336         exception_lineno = 30;
337  
338         goto frame_exception_exit_1;
339     }
340  
341     frame_28de6027e6fa7762740724bc2b706691->m_frame.f_lineno = 30;
342     tmp_unused = CALL_FUNCTION_NO_ARGS( tmp_called_name_2 );
343     if ( tmp_unused == NULL )
344     {
345         assert( ERROR_OCCURRED() );
346  
347         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
348  
349  
350         exception_lineno = 30;
351  
352         goto frame_exception_exit_1;
353     }
354     Py_DECREF( tmp_unused );
355     tmp_called_name_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_compiled_func );
356  
357     if (unlikely( tmp_called_name_3 == NULL ))
358     {
359         tmp_called_name_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_compiled_func );
360     }
361  
362     if ( tmp_called_name_3 == NULL )
363     {
364  
365         exception_type = PyExc_NameError;
366         Py_INCREF( exception_type );
367         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "compiled_func" );
368         exception_tb = NULL;
369         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
370         CHAIN_EXCEPTION( exception_value );
371  
372         exception_lineno = 31;
373  
374         goto frame_exception_exit_1;
375     }
376  
377     frame_28de6027e6fa7762740724bc2b706691->m_frame.f_lineno = 31;
378     tmp_unused = CALL_FUNCTION_NO_ARGS( tmp_called_name_3 );
379     if ( tmp_unused == NULL )
380     {
381         assert( ERROR_OCCURRED() );
382  
383         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
384  
385  
386         exception_lineno = 31;
387  
388         goto frame_exception_exit_1;
389     }
390     Py_DECREF( tmp_unused );
391  
392 #if 0
393     RESTORE_FRAME_EXCEPTION( frame_28de6027e6fa7762740724bc2b706691 );
394 #endif
395  
396     // Put the previous frame back on top.
397     popFrameStack();
398  
399     goto frame_no_exception_1;
400  
401     frame_exception_exit_1:;
402  
403 #if 0
404     RESTORE_FRAME_EXCEPTION( frame_28de6027e6fa7762740724bc2b706691 );
405 #endif
406  
407     if ( exception_tb == NULL )
408     {
409         exception_tb = MAKE_TRACEBACK( frame_28de6027e6fa7762740724bc2b706691, exception_lineno );
410     }
411     else if ( exception_tb->tb_frame != &frame_28de6027e6fa7762740724bc2b706691->m_frame )
412     {
413         exception_tb = ADD_TRACEBACK( exception_tb, frame_28de6027e6fa7762740724bc2b706691, exception_lineno );
414     }
415  
416     Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)frame_28de6027e6fa7762740724bc2b706691, ""  );
417  
418     // Release cached frame.
419     if ( frame_28de6027e6fa7762740724bc2b706691 == cache_frame_28de6027e6fa7762740724bc2b706691 )
420     {
421         Py_DECREF( frame_28de6027e6fa7762740724bc2b706691 );
422     }
423     cache_frame_28de6027e6fa7762740724bc2b706691 = NULL;
424  
425     assertFrameObject( frame_28de6027e6fa7762740724bc2b706691 );
426  
427  
428     // Put the previous frame back on top.
429     popFrameStack();
430  
431     // Return the error.
432     goto function_exception_exit;
433  
434     frame_no_exception_1:;
435  
436     tmp_return_value = Py_None; 261     tmp_return_value = Py_None;
437     Py_INCREF( tmp_return_value ); 262     Py_INCREF( tmp_return_value );
438     goto function_return_exit; 263     goto function_return_exit;
439 264
440     // Return statement must have exited already. 265     // Return statement must have exited already.
441     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly ); 266     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly );
442     return NULL; 267     return NULL;
443 268
n 444 function_exception_exit: n
445     assert( exception_type );
446     RESTORE_ERROR_OCCURRED( exception_type, exception_value, exception_tb );
447  
448     return NULL;
449     function_return_exit: 269     function_return_exit:
450 270
451     CHECK_OBJECT( tmp_return_value ); 271     CHECK_OBJECT( tmp_return_value );
452     assert( had_error || !ERROR_OCCURRED() ); 272     assert( had_error || !ERROR_OCCURRED() );
453     return tmp_return_value; 273     return tmp_return_value;
487         impl___main__$$$function_2_calledRepeatedly, 307         impl___main__$$$function_2_calledRepeatedly,
488         const_str_plain_calledRepeatedly, 308         const_str_plain_calledRepeatedly,
489 #if PYTHON_VERSION >= 330 309 #if PYTHON_VERSION >= 330
490         NULL, 310         NULL,
491 #endif 311 #endif
t 492         codeobj_28de6027e6fa7762740724bc2b706691, t 312         codeobj_1a85ae15eb74d911679d9bd4182bd2d7,
493         NULL, 313         NULL,
494 #if PYTHON_VERSION >= 300 314 #if PYTHON_VERSION >= 300
495         NULL, 315         NULL,
496         const_dict_empty, 316         const_dict_empty,
497 #endif 317 #endif