Construct CallCompiledFunctionPosArgsDefaults

Performance Diagrams

Construct CallCompiledFunctionPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)19153270772.9230769230769257.0CPython 2.785599914194.46153846153845393.6744265018764Nuitka (historic)63850143316.0421.73596810563777Nuitka (master)63849759437.53846153846143421.7364635422093Nuitka (develop)63850300559.0769230769231421.7357655443312Nuitka (factory)Construct CallCompiledFunctionPosArgsDefaultsTicks Construct CallCompiledFunctionPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)19954388372.9230769230769257.0CPython 3.50194.46153846153845504.11538461538464Nuitka (historic)73648794316.0412.90862957910406Nuitka (master)73657988437.53846153846143412.8972437184503Nuitka (develop)73656748559.0769230769231412.8987793359411Nuitka (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



for x in xrange(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

for x in xrange(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 for x in xrange(50000): 36 for x in xrange(50000):
37     calledRepeatedly() 37     calledRepeatedly()
38 38
39 print("OK.") 39 print("OK.")

Context Diff of Generated Code


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