Construct CallCompiledMethodPosArgsDefaults

Performance Diagrams

Construct CallCompiledMethodPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)21710056072.9230769230769257.0CPython 2.7114800160194.46153846153845373.44374704656536Nuitka (historic)99352397316.0391.0272111112933Nuitka (master)99352505437.53846153846143391.0270881799589Nuitka (develop)88551796559.0769230769231403.3210286407935Nuitka (factory)Construct CallCompiledMethodPosArgsDefaultsTicks Construct CallCompiledMethodPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)20075147872.9230769230769257.0CPython 3.50194.46153846153845504.11538461538464Nuitka (historic)92851917316.0389.8191542198566Nuitka (master)92852020437.53846153846143389.81902743182565Nuitka (develop)92852142559.0769230769231389.81887725571124Nuitka (factory)Construct CallCompiledMethodPosArgsDefaultsTicks

Source Code with Construct

from __future__ import print_function

class C:
    def compiled_method(self, a = 1, b = 2,c = 3,d = 4,e = 5,f = 6):
        return a, b, c, d, e, f

def calledRepeatedly():
    inst = C()

    # This is supposed to make a call to a non-compiled function, which is
    # being optimized separately.
# construct_begin
    inst.compiled_method()
    inst.compiled_method()
    inst.compiled_method()
# construct_alternative



for x in xrange(50000):
    calledRepeatedly()

print("OK.")

Source Code without Construct

from __future__ import print_function

class C:
    def compiled_method(self, a = 1, b = 2,c = 3,d = 4,e = 5,f = 6):
        return a, b, c, d, e, f

def calledRepeatedly():
    inst = C()

    # 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
27     inst = C() 27     inst = C()
28 28
29     # This is supposed to make a call to a non-compiled function, which is 29     # This is supposed to make a call to a non-compiled function, which is
30     # being optimized separately. 30     # being optimized separately.
31 # construct_begin 31 # construct_begin
n 32     inst.compiled_method() n
33     inst.compiled_method()
34     inst.compiled_method()
35 # construct_alternative
36 32
37 33
t t 34  
35 # construct_alternative
36     pass
37 # construct_end
38 38
39 for x in xrange(50000): 39 for x in xrange(50000):
40     calledRepeatedly() 40     calledRepeatedly()
41 41
42 print("OK.") 42 print("OK.")

Context Diff of Generated Code


Construct
Baseline
482     PyObject *exception_keeper_value_1; 482     PyObject *exception_keeper_value_1;
483     PyTracebackObject *exception_keeper_tb_1; 483     PyTracebackObject *exception_keeper_tb_1;
484     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 484     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
485     PyObject *tmp_assign_source_1; 485     PyObject *tmp_assign_source_1;
486     PyObject *tmp_called_name_1; 486     PyObject *tmp_called_name_1;
n 487     PyObject *tmp_called_name_2; n
488     PyObject *tmp_called_name_3;
489     PyObject *tmp_called_name_4;
490     PyObject *tmp_frame_locals; 487     PyObject *tmp_frame_locals;
491     PyObject *tmp_return_value; 488     PyObject *tmp_return_value;
n 492     PyObject *tmp_source_name_1; n
493     PyObject *tmp_source_name_2;
494     PyObject *tmp_source_name_3;
495     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
496     static PyFrameObject *cache_frame_function = NULL; 489     static PyFrameObject *cache_frame_function = NULL;
497 490
498     PyFrameObject *frame_function; 491     PyFrameObject *frame_function;
499 492
500     tmp_return_value = NULL; 493     tmp_return_value = NULL;
550         goto frame_exception_exit_1; 543         goto frame_exception_exit_1;
551     } 544     }
552     assert( var_inst == NULL ); 545     assert( var_inst == NULL );
553     var_inst = tmp_assign_source_1; 546     var_inst = tmp_assign_source_1;
554 547
n 555     tmp_source_name_1 = var_inst; n
556  
557     tmp_called_name_2 = LOOKUP_ATTRIBUTE( tmp_source_name_1, const_str_plain_compiled_method );
558     if ( tmp_called_name_2 == NULL )
559     {
560         assert( ERROR_OCCURRED() );
561  
562         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
563  
564  
565         exception_lineno = 32;
566         goto frame_exception_exit_1;
567     }
568     frame_function->f_lineno = 32;
569     tmp_unused = CALL_FUNCTION_NO_ARGS( tmp_called_name_2 );
570     Py_DECREF( tmp_called_name_2 );
571     if ( tmp_unused == NULL )
572     {
573         assert( ERROR_OCCURRED() );
574  
575         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
576  
577  
578         exception_lineno = 32;
579         goto frame_exception_exit_1;
580     }
581     Py_DECREF( tmp_unused );
582     tmp_source_name_2 = var_inst;
583  
584     if ( tmp_source_name_2 == NULL )
585     {
586  
587         exception_type = PyExc_UnboundLocalError;
588         Py_INCREF( exception_type );
589         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
590         exception_tb = NULL;
591         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
592         CHAIN_EXCEPTION( exception_value );
593  
594         exception_lineno = 33;
595         goto frame_exception_exit_1;
596     }
597  
598     tmp_called_name_3 = LOOKUP_ATTRIBUTE( tmp_source_name_2, const_str_plain_compiled_method );
599     if ( tmp_called_name_3 == NULL )
600     {
601         assert( ERROR_OCCURRED() );
602  
603         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
604  
605  
606         exception_lineno = 33;
607         goto frame_exception_exit_1;
608     }
609     frame_function->f_lineno = 33;
610     tmp_unused = CALL_FUNCTION_NO_ARGS( tmp_called_name_3 );
611     Py_DECREF( tmp_called_name_3 );
612     if ( tmp_unused == NULL )
613     {
614         assert( ERROR_OCCURRED() );
615  
616         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
617  
618  
619         exception_lineno = 33;
620         goto frame_exception_exit_1;
621     }
622     Py_DECREF( tmp_unused );
623     tmp_source_name_3 = var_inst;
624  
625     if ( tmp_source_name_3 == NULL )
626     {
627  
628         exception_type = PyExc_UnboundLocalError;
629         Py_INCREF( exception_type );
630         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
631         exception_tb = NULL;
632         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
633         CHAIN_EXCEPTION( exception_value );
634  
635         exception_lineno = 34;
636         goto frame_exception_exit_1;
637     }
638  
639     tmp_called_name_4 = LOOKUP_ATTRIBUTE( tmp_source_name_3, const_str_plain_compiled_method );
640     if ( tmp_called_name_4 == NULL )
641     {
642         assert( ERROR_OCCURRED() );
643  
644         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
645  
646  
647         exception_lineno = 34;
648         goto frame_exception_exit_1;
649     }
650     frame_function->f_lineno = 34;
651     tmp_unused = CALL_FUNCTION_NO_ARGS( tmp_called_name_4 );
652     Py_DECREF( tmp_called_name_4 );
653     if ( tmp_unused == NULL )
654     {
655         assert( ERROR_OCCURRED() );
656  
657         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
658  
659  
660         exception_lineno = 34;
661         goto frame_exception_exit_1;
662     }
663     Py_DECREF( tmp_unused );
664 548
665 #if 0 549 #if 0
666     RESTORE_FRAME_EXCEPTION( frame_function ); 550     RESTORE_FRAME_EXCEPTION( frame_function );
667 #endif 551 #endif
668     // Put the previous frame back on top. 552     // Put the previous frame back on top.
734     // tried codes exits in all cases 618     // tried codes exits in all cases
735     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 619     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
736     return NULL; 620     return NULL;
737     // Return handler code: 621     // Return handler code:
738     try_return_handler_1:; 622     try_return_handler_1:;
n n 623     CHECK_OBJECT( (PyObject *)var_inst );
739     Py_XDECREF( var_inst ); 624     Py_DECREF( var_inst );
740     var_inst = NULL; 625     var_inst = NULL;
741 626
742     goto function_return_exit; 627     goto function_return_exit;
743     // Exception handler code: 628     // Exception handler code:
744     try_except_handler_1:; 629     try_except_handler_1:;
748     exception_keeper_lineno_1 = exception_lineno; 633     exception_keeper_lineno_1 = exception_lineno;
749     exception_type = NULL; 634     exception_type = NULL;
750     exception_value = NULL; 635     exception_value = NULL;
751     exception_tb = NULL; 636     exception_tb = NULL;
752     exception_lineno = -1; 637     exception_lineno = -1;
t 753   t
754     Py_XDECREF( var_inst );
755     var_inst = NULL;
756 638
757     // Re-raise. 639     // Re-raise.
758     exception_type = exception_keeper_type_1; 640     exception_type = exception_keeper_type_1;
759     exception_value = exception_keeper_value_1; 641     exception_value = exception_keeper_value_1;
760     exception_tb = exception_keeper_tb_1; 642     exception_tb = exception_keeper_tb_1;