Construct CallCompiledFunctionPosArgsDefaults

Performance Diagrams

Construct CallCompiledFunctionPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)19153270772.9230769230769257.0CPython 2.785599914194.46153846153845393.6744265018764Nuitka (historic)64399538316.0421.02713900351074Nuitka (master)64400192437.53846153846143421.02629521309984Nuitka (develop)63850798559.0769230769231421.73512302502746Nuitka (factory)Construct CallCompiledFunctionPosArgsDefaultsTicks Construct CallCompiledFunctionPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)19954388372.9230769230769257.0CPython 3.50194.46153846153845504.11538461538464Nuitka (historic)73995579316.0412.47917061817043Nuitka (master)74299995437.53846153846143412.1021814777763Nuitka (develop)73649494559.0769230769231412.90776269826245Nuitka (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
236 #ifndef __NUITKA_NO_ASSERT__ 236 #ifndef __NUITKA_NO_ASSERT__
237     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 237     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
238 #endif 238 #endif
239 239
240     // Local variable declarations. 240     // Local variable declarations.
n 241     PyObject *exception_type = NULL, *exception_value = NULL; n
242     PyTracebackObject *exception_tb = NULL;
243     NUITKA_MAY_BE_UNUSED int exception_lineno = -1;
244     PyObject *tmp_called_name_1;
245     PyObject *tmp_called_name_2;
246     PyObject *tmp_called_name_3;
247     PyObject *tmp_return_value; 241     PyObject *tmp_return_value;
n 248     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
249     static struct Nuitka_FrameObject *cache_frame_function = NULL;
250  
251     struct Nuitka_FrameObject *frame_function;
252  
253     tmp_return_value = NULL; 242     tmp_return_value = NULL;
254 243
255     // Actual function code. 244     // Actual function code.
n 256     MAKE_OR_REUSE_FRAME( cache_frame_function, codeobj_91297251810dff113f18a3f4c9133fac, module___main__, 0 ); n
257     frame_function = cache_frame_function;
258  
259     // Push the new frame as the currently active one.
260     pushFrameStack( frame_function );
261  
262     // Mark the frame object as in use, ref count 1 will be up for reuse.
263     assert( Py_REFCNT( frame_function ) == 2 ); // Frame stack
264  
265     // Framed code:
266     tmp_called_name_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_compiled_func );
267  
268     if (unlikely( tmp_called_name_1 == NULL ))
269     {
270         tmp_called_name_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_compiled_func );
271     }
272  
273     if ( tmp_called_name_1 == NULL )
274     {
275  
276         exception_type = PyExc_NameError;
277         Py_INCREF( exception_type );
278         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "compiled_func" );
279         exception_tb = NULL;
280         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
281         CHAIN_EXCEPTION( exception_value );
282  
283         exception_lineno = 29;
284  
285         goto frame_exception_exit_1;
286     }
287  
288     frame_function->m_frame.f_lineno = 29;
289     tmp_unused = CALL_FUNCTION_NO_ARGS( tmp_called_name_1 );
290     if ( tmp_unused == NULL )
291     {
292         assert( ERROR_OCCURRED() );
293  
294         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
295  
296  
297         exception_lineno = 29;
298  
299         goto frame_exception_exit_1;
300     }
301     Py_DECREF( tmp_unused );
302     tmp_called_name_2 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_compiled_func );
303  
304     if (unlikely( tmp_called_name_2 == NULL ))
305     {
306         tmp_called_name_2 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_compiled_func );
307     }
308  
309     if ( tmp_called_name_2 == NULL )
310     {
311  
312         exception_type = PyExc_NameError;
313         Py_INCREF( exception_type );
314         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "compiled_func" );
315         exception_tb = NULL;
316         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
317         CHAIN_EXCEPTION( exception_value );
318  
319         exception_lineno = 30;
320  
321         goto frame_exception_exit_1;
322     }
323  
324     frame_function->m_frame.f_lineno = 30;
325     tmp_unused = CALL_FUNCTION_NO_ARGS( tmp_called_name_2 );
326     if ( tmp_unused == NULL )
327     {
328         assert( ERROR_OCCURRED() );
329  
330         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
331  
332  
333         exception_lineno = 30;
334  
335         goto frame_exception_exit_1;
336     }
337     Py_DECREF( tmp_unused );
338     tmp_called_name_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_compiled_func );
339  
340     if (unlikely( tmp_called_name_3 == NULL ))
341     {
342         tmp_called_name_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_compiled_func );
343     }
344  
345     if ( tmp_called_name_3 == NULL )
346     {
347  
348         exception_type = PyExc_NameError;
349         Py_INCREF( exception_type );
350         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "compiled_func" );
351         exception_tb = NULL;
352         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
353         CHAIN_EXCEPTION( exception_value );
354  
355         exception_lineno = 31;
356  
357         goto frame_exception_exit_1;
358     }
359  
360     frame_function->m_frame.f_lineno = 31;
361     tmp_unused = CALL_FUNCTION_NO_ARGS( tmp_called_name_3 );
362     if ( tmp_unused == NULL )
363     {
364         assert( ERROR_OCCURRED() );
365  
366         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
367  
368  
369         exception_lineno = 31;
370  
371         goto frame_exception_exit_1;
372     }
373     Py_DECREF( tmp_unused );
374  
375 #if 0
376     RESTORE_FRAME_EXCEPTION( frame_function );
377 #endif
378  
379     // Put the previous frame back on top.
380     popFrameStack();
381  
382     goto frame_no_exception_1;
383  
384     frame_exception_exit_1:;
385  
386 #if 0
387     RESTORE_FRAME_EXCEPTION( frame_function );
388 #endif
389  
390     if ( exception_tb == NULL )
391     {
392         exception_tb = MAKE_TRACEBACK( frame_function, exception_lineno );
393     }
394     else if ( exception_tb->tb_frame != &frame_function->m_frame )
395     {
396         exception_tb = ADD_TRACEBACK( exception_tb, frame_function, exception_lineno );
397     }
398  
399     Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)frame_function, ""  );
400  
401     // Release cached frame.
402     if ( frame_function == cache_frame_function )
403     {
404         Py_DECREF( frame_function );
405     }
406     cache_frame_function = NULL;
407  
408     assertFrameObject( frame_function );
409  
410  
411     // Put the previous frame back on top.
412     popFrameStack();
413  
414     // Return the error.
415     goto function_exception_exit;
416  
417     frame_no_exception_1:;
418  
419     tmp_return_value = Py_None; 245     tmp_return_value = Py_None;
420     Py_INCREF( tmp_return_value ); 246     Py_INCREF( tmp_return_value );
421     goto function_return_exit; 247     goto function_return_exit;
422 248
423     // Return statement must have exited already. 249     // Return statement must have exited already.
424     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly ); 250     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly );
425     return NULL; 251     return NULL;
426 252
t 427 function_exception_exit: t
428     assert( exception_type );
429     RESTORE_ERROR_OCCURRED( exception_type, exception_value, exception_tb );
430  
431     return NULL;
432     function_return_exit: 253     function_return_exit:
433 254
434     CHECK_OBJECT( tmp_return_value ); 255     CHECK_OBJECT( tmp_return_value );
435     assert( had_error || !ERROR_OCCURRED() ); 256     assert( had_error || !ERROR_OCCURRED() );
436     return tmp_return_value; 257     return tmp_return_value;