Construct CallCompiledFunctionPosArgsDefaults

Performance Diagrams

Construct CallCompiledFunctionPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)20339423088.11538461538461257.0CPython 2.764250196240.03846153846155426.05411465628185Nuitka (master)64250340391.96153846153845426.0539397023739Nuitka (develop)64250150543.8846153846154426.05417054433576Nuitka (factory)Construct CallCompiledFunctionPosArgsDefaultsTicks Construct CallCompiledFunctionPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)20133875588.11538461538461257.0CPython 3.573505260240.03846153846155413.8978773294483Nuitka (master)73503682391.96153846153845413.8998141054899Nuitka (develop)73506291543.8846153846154413.8966119200067Nuitka (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_08b0a93fe3e3d23753017306065f09d8; 134 static PyCodeObject *codeobj_08b0a93fe3e3d23753017306065f09d8;
n 135 static PyCodeObject *codeobj_b6300c15613d593edd80f84688cf47e1; n 135 static PyCodeObject *codeobj_f8cf26d8f27b9d8ef980b5f95af604f5;
136 static PyCodeObject *codeobj_d390fb45ad5c450d925410aeb0ddc30b; 136 static PyCodeObject *codeobj_d390fb45ad5c450d925410aeb0ddc30b;
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_7cdecd03548cb40f420ca5f5785a4b71; 142     module_filename_obj = const_str_digest_7cdecd03548cb40f420ca5f5785a4b71;
143     codeobj_08b0a93fe3e3d23753017306065f09d8 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE ); 143     codeobj_08b0a93fe3e3d23753017306065f09d8 = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE );
144     codeobj_main = codeobj_08b0a93fe3e3d23753017306065f09d8; 144     codeobj_main = codeobj_08b0a93fe3e3d23753017306065f09d8;
n 145     codeobj_b6300c15613d593edd80f84688cf47e1 = MAKE_CODEOBJ( module_filename_obj, const_str_plain_calledRepeatedly, 25, const_tuple_empty, 0, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE ); n 145     codeobj_f8cf26d8f27b9d8ef980b5f95af604f5 = MAKE_CODEOBJ( module_filename_obj, const_str_plain_calledRepeatedly, 25, const_tuple_empty, 0, 0, CO_NOFREE );
146     codeobj_d390fb45ad5c450d925410aeb0ddc30b = 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_d390fb45ad5c450d925410aeb0ddc30b = 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_b6300c15613d593edd80f84688cf47e1 = NULL;
267  
268     struct Nuitka_FrameObject *frame_b6300c15613d593edd80f84688cf47e1;
269  
270     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
271     tmp_return_value = NULL; 258     tmp_return_value = NULL;
272 259
273     // Actual function code. 260     // Actual function code.
n 274     MAKE_OR_REUSE_FRAME( cache_frame_b6300c15613d593edd80f84688cf47e1, codeobj_b6300c15613d593edd80f84688cf47e1, module___main__, 0 ); n
275     frame_b6300c15613d593edd80f84688cf47e1 = cache_frame_b6300c15613d593edd80f84688cf47e1;
276  
277     // Push the new frame as the currently active one.
278     pushFrameStack( frame_b6300c15613d593edd80f84688cf47e1 );
279  
280     // Mark the frame object as in use, ref count 1 will be up for reuse.
281     assert( Py_REFCNT( frame_b6300c15613d593edd80f84688cf47e1 ) == 2 ); // Frame stack
282  
283     // Framed code:
284     tmp_called_name_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_compiled_func );
285  
286     if (unlikely( tmp_called_name_1 == NULL ))
287     {
288         tmp_called_name_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_compiled_func );
289     }
290  
291     if ( tmp_called_name_1 == NULL )
292     {
293  
294         exception_type = PyExc_NameError;
295         Py_INCREF( exception_type );
296         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "compiled_func" );
297         exception_tb = NULL;
298         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
299         CHAIN_EXCEPTION( exception_value );
300  
301         exception_lineno = 29;
302  
303         goto frame_exception_exit_1;
304     }
305  
306     frame_b6300c15613d593edd80f84688cf47e1->m_frame.f_lineno = 29;
307     tmp_unused = CALL_FUNCTION_NO_ARGS( tmp_called_name_1 );
308     if ( tmp_unused == NULL )
309     {
310         assert( ERROR_OCCURRED() );
311  
312         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
313  
314  
315         exception_lineno = 29;
316  
317         goto frame_exception_exit_1;
318     }
319     Py_DECREF( tmp_unused );
320     tmp_called_name_2 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_compiled_func );
321  
322     if (unlikely( tmp_called_name_2 == NULL ))
323     {
324         tmp_called_name_2 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_compiled_func );
325     }
326  
327     if ( tmp_called_name_2 == NULL )
328     {
329  
330         exception_type = PyExc_NameError;
331         Py_INCREF( exception_type );
332         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "compiled_func" );
333         exception_tb = NULL;
334         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
335         CHAIN_EXCEPTION( exception_value );
336  
337         exception_lineno = 30;
338  
339         goto frame_exception_exit_1;
340     }
341  
342     frame_b6300c15613d593edd80f84688cf47e1->m_frame.f_lineno = 30;
343     tmp_unused = CALL_FUNCTION_NO_ARGS( tmp_called_name_2 );
344     if ( tmp_unused == NULL )
345     {
346         assert( ERROR_OCCURRED() );
347  
348         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
349  
350  
351         exception_lineno = 30;
352  
353         goto frame_exception_exit_1;
354     }
355     Py_DECREF( tmp_unused );
356     tmp_called_name_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_compiled_func );
357  
358     if (unlikely( tmp_called_name_3 == NULL ))
359     {
360         tmp_called_name_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_compiled_func );
361     }
362  
363     if ( tmp_called_name_3 == NULL )
364     {
365  
366         exception_type = PyExc_NameError;
367         Py_INCREF( exception_type );
368         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "compiled_func" );
369         exception_tb = NULL;
370         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
371         CHAIN_EXCEPTION( exception_value );
372  
373         exception_lineno = 31;
374  
375         goto frame_exception_exit_1;
376     }
377  
378     frame_b6300c15613d593edd80f84688cf47e1->m_frame.f_lineno = 31;
379     tmp_unused = CALL_FUNCTION_NO_ARGS( tmp_called_name_3 );
380     if ( tmp_unused == NULL )
381     {
382         assert( ERROR_OCCURRED() );
383  
384         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
385  
386  
387         exception_lineno = 31;
388  
389         goto frame_exception_exit_1;
390     }
391     Py_DECREF( tmp_unused );
392  
393 #if 0
394     RESTORE_FRAME_EXCEPTION( frame_b6300c15613d593edd80f84688cf47e1 );
395 #endif
396  
397     // Put the previous frame back on top.
398     popFrameStack();
399  
400     goto frame_no_exception_1;
401  
402     frame_exception_exit_1:;
403  
404 #if 0
405     RESTORE_FRAME_EXCEPTION( frame_b6300c15613d593edd80f84688cf47e1 );
406 #endif
407  
408     if ( exception_tb == NULL )
409     {
410         exception_tb = MAKE_TRACEBACK( frame_b6300c15613d593edd80f84688cf47e1, exception_lineno );
411     }
412     else if ( exception_tb->tb_frame != &frame_b6300c15613d593edd80f84688cf47e1->m_frame )
413     {
414         exception_tb = ADD_TRACEBACK( exception_tb, frame_b6300c15613d593edd80f84688cf47e1, exception_lineno );
415     }
416  
417     // Attachs locals to frame if any.
418     Nuitka_Frame_AttachLocals(
419         (struct Nuitka_FrameObject *)frame_b6300c15613d593edd80f84688cf47e1,
420         type_description_1
421     );
422  
423  
424     // Release cached frame.
425     if ( frame_b6300c15613d593edd80f84688cf47e1 == cache_frame_b6300c15613d593edd80f84688cf47e1 )
426     {
427         Py_DECREF( frame_b6300c15613d593edd80f84688cf47e1 );
428     }
429     cache_frame_b6300c15613d593edd80f84688cf47e1 = NULL;
430  
431     assertFrameObject( frame_b6300c15613d593edd80f84688cf47e1 );
432  
433     // Put the previous frame back on top.
434     popFrameStack();
435  
436     // Return the error.
437     goto function_exception_exit;
438  
439     frame_no_exception_1:;
440  
441     tmp_return_value = Py_None; 261     tmp_return_value = Py_None;
442     Py_INCREF( tmp_return_value ); 262     Py_INCREF( tmp_return_value );
443     goto function_return_exit; 263     goto function_return_exit;
444 264
445     // Return statement must have exited already. 265     // Return statement must have exited already.
446     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly ); 266     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly );
447     return NULL; 267     return NULL;
448 268
n 449 function_exception_exit: n
450     assert( exception_type );
451     RESTORE_ERROR_OCCURRED( exception_type, exception_value, exception_tb );
452  
453     return NULL;
454 function_return_exit: 269 function_return_exit:
455 270
456 CHECK_OBJECT( tmp_return_value ); 271 CHECK_OBJECT( tmp_return_value );
457 assert( had_error || !ERROR_OCCURRED() ); 272 assert( had_error || !ERROR_OCCURRED() );
458 return tmp_return_value; 273 return tmp_return_value;
492         impl___main__$$$function_2_calledRepeatedly, 307         impl___main__$$$function_2_calledRepeatedly,
493         const_str_plain_calledRepeatedly, 308         const_str_plain_calledRepeatedly,
494 #if PYTHON_VERSION >= 330 309 #if PYTHON_VERSION >= 330
495         NULL, 310         NULL,
496 #endif 311 #endif
t 497         codeobj_b6300c15613d593edd80f84688cf47e1, t 312         codeobj_f8cf26d8f27b9d8ef980b5f95af604f5,
498         NULL, 313         NULL,
499 #if PYTHON_VERSION >= 300 314 #if PYTHON_VERSION >= 300
500         NULL, 315         NULL,
501         const_dict_empty, 316         const_dict_empty,
502 #endif 317 #endif