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)64400229437.53846153846143421.02624747572185Nuitka (develop)64399630559.0769230769231421.0270203051655Nuitka (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)74000983437.53846153846143412.47247829807327Nuitka (develop)74001486559.0769230769231412.47185538226853Nuitka (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_frame_locals;
248     PyObject *tmp_return_value; 241     PyObject *tmp_return_value;
n 249     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
250     static PyFrameObject *cache_frame_function = NULL;
251  
252     PyFrameObject *frame_function;
253  
254     tmp_return_value = NULL; 242     tmp_return_value = NULL;
255 243
256     // Actual function code. 244     // Actual function code.
n 257     MAKE_OR_REUSE_FRAME( cache_frame_function, codeobj_ae35dcfb13a53b5a6b1d4ae3129331a6, module___main__ ); n
258     frame_function = cache_frame_function;
259  
260     // Push the new frame as the currently active one.
261     pushFrameStack( frame_function );
262  
263     // Mark the frame object as in use, ref count 1 will be up for reuse.
264     Py_INCREF( frame_function );
265     assert( Py_REFCNT( frame_function ) == 2 ); // Frame stack
266  
267 #if PYTHON_VERSION >= 340
268     frame_function->f_executing += 1;
269 #endif
270  
271     // Framed code:
272     tmp_called_name_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_compiled_func );
273  
274     if (unlikely( tmp_called_name_1 == NULL ))
275     {
276         tmp_called_name_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_compiled_func );
277     }
278  
279     if ( tmp_called_name_1 == NULL )
280     {
281  
282         exception_type = PyExc_NameError;
283         Py_INCREF( exception_type );
284         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "compiled_func" );
285         exception_tb = NULL;
286         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
287         CHAIN_EXCEPTION( exception_value );
288  
289         exception_lineno = 29;
290         goto frame_exception_exit_1;
291     }
292  
293     frame_function->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         goto frame_exception_exit_1;
304     }
305     Py_DECREF( tmp_unused );
306     tmp_called_name_2 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_compiled_func );
307  
308     if (unlikely( tmp_called_name_2 == NULL ))
309     {
310         tmp_called_name_2 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_compiled_func );
311     }
312  
313     if ( tmp_called_name_2 == NULL )
314     {
315  
316         exception_type = PyExc_NameError;
317         Py_INCREF( exception_type );
318         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "compiled_func" );
319         exception_tb = NULL;
320         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
321         CHAIN_EXCEPTION( exception_value );
322  
323         exception_lineno = 30;
324         goto frame_exception_exit_1;
325     }
326  
327     frame_function->f_lineno = 30;
328     tmp_unused = CALL_FUNCTION_NO_ARGS( tmp_called_name_2 );
329     if ( tmp_unused == NULL )
330     {
331         assert( ERROR_OCCURRED() );
332  
333         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
334  
335  
336         exception_lineno = 30;
337         goto frame_exception_exit_1;
338     }
339     Py_DECREF( tmp_unused );
340     tmp_called_name_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_compiled_func );
341  
342     if (unlikely( tmp_called_name_3 == NULL ))
343     {
344         tmp_called_name_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_compiled_func );
345     }
346  
347     if ( tmp_called_name_3 == NULL )
348     {
349  
350         exception_type = PyExc_NameError;
351         Py_INCREF( exception_type );
352         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "compiled_func" );
353         exception_tb = NULL;
354         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
355         CHAIN_EXCEPTION( exception_value );
356  
357         exception_lineno = 31;
358         goto frame_exception_exit_1;
359     }
360  
361     frame_function->f_lineno = 31;
362     tmp_unused = CALL_FUNCTION_NO_ARGS( tmp_called_name_3 );
363     if ( tmp_unused == NULL )
364     {
365         assert( ERROR_OCCURRED() );
366  
367         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
368  
369  
370         exception_lineno = 31;
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     // Put the previous frame back on top.
379     popFrameStack();
380 #if PYTHON_VERSION >= 340
381     frame_function->f_executing -= 1;
382 #endif
383     Py_DECREF( frame_function );
384     goto frame_no_exception_1;
385  
386     frame_exception_exit_1:;
387 #if 0
388     RESTORE_FRAME_EXCEPTION( frame_function );
389 #endif
390  
391     {
392         bool needs_detach = false;
393  
394         if ( exception_tb == NULL )
395         {
396             exception_tb = MAKE_TRACEBACK( frame_function, exception_lineno );
397             needs_detach = true;
398         }
399         else if ( exception_lineno != -1 )
400         {
401             PyTracebackObject *traceback_new = MAKE_TRACEBACK( frame_function, exception_lineno );
402             traceback_new->tb_next = exception_tb;
403             exception_tb = traceback_new;
404  
405             needs_detach = true;
406         }
407  
408         if (needs_detach)
409         {
410  
411             tmp_frame_locals = PyDict_New();
412  
413  
414             detachFrame( exception_tb, tmp_frame_locals );
415         }
416     }
417  
418     popFrameStack();
419  
420 #if PYTHON_VERSION >= 340
421     frame_function->f_executing -= 1;
422 #endif
423     Py_DECREF( frame_function );
424  
425     // Return the error.
426     goto function_exception_exit;
427  
428     frame_no_exception_1:;
429  
430     tmp_return_value = Py_None; 245     tmp_return_value = Py_None;
431     Py_INCREF( tmp_return_value ); 246     Py_INCREF( tmp_return_value );
432     goto function_return_exit; 247     goto function_return_exit;
433 248
434     // Return statement must have exited already. 249     // Return statement must have exited already.
435     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly ); 250     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly );
436     return NULL; 251     return NULL;
437 252
t 438 function_exception_exit: t
439     assert( exception_type );
440     RESTORE_ERROR_OCCURRED( exception_type, exception_value, exception_tb );
441  
442     return NULL;
443     function_return_exit: 253     function_return_exit:
444 254
445     CHECK_OBJECT( tmp_return_value ); 255     CHECK_OBJECT( tmp_return_value );
446     assert( had_error || !ERROR_OCCURRED() ); 256     assert( had_error || !ERROR_OCCURRED() );
447     return tmp_return_value; 257     return tmp_return_value;