Construct InplaceOperationInstanceStringAdd

Performance Diagrams

Construct InplaceOperationInstanceStringAdd 001000000001000000002000000002000000003000000003000000004000000004000000005000000005000000006000000006000000007000000007000000008000000008000000009000000009000000001000000000100000000011000000001100000000120000000012000000001300000000130000000014000000001400000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)143084968672.23076923076923257.0CPython 2.71420700532192.61538461538458258.7528131143126Nuitka (historic)1417250764313.0259.34860647716187Nuitka (master)1417457782433.38461538461536259.3128533626364Nuitka (develop)1417450780553.7692307692307259.3140626454423Nuitka (factory)Construct InplaceOperationInstanceStringAddTicks Construct InplaceOperationInstanceStringAdd 001000000001000000002000000002000000003000000003000000004000000004000000005000000005000000006000000006000000007000000007000000008000000008000000009000000009000000001000000000100000000011000000001100000000120000000012000000001300000000130000000014000000001400000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)144968386672.23076923076923257.0CPython 3.50192.61538461538458504.11538461538464Nuitka (historic)1439661014313.0258.7085110657657Nuitka (master)1439649681433.38461538461536258.71044290671364Nuitka (develop)1440763321553.7692307692307258.5206100863468Nuitka (factory)Construct InplaceOperationInstanceStringAddTicks

Source Code with Construct

module_value1 = 5

class C:
    def __init__(self):

        self.s = '2' * 100000

    def increment(self):
        additiv = '*' * 1000

# construct_begin
        self.s += additiv
# construct_end

        return additiv

def calledRepeatedly():
    # Force frame and eliminate forward propagation (currently).
    module_value1

    local_value = C()

    local_value.increment()

for x in xrange(50000):
    calledRepeatedly()

print("OK.")

Source Code without Construct

module_value1 = 5

class C:
    def __init__(self):

        self.s = '2' * 100000

    def increment(self):
        additiv = '*' * 1000

# construct_begin



        return additiv

def calledRepeatedly():
    # Force frame and eliminate forward propagation (currently).
    module_value1

    local_value = C()

    local_value.increment()

for x in xrange(50000):
    calledRepeatedly()

print("OK.")

Context Diff of Source Code


Construct
Baseline
27 27
28     def increment(self): 28     def increment(self):
29         additiv = '*' * 1000 29         additiv = '*' * 1000
30 30
31 # construct_begin 31 # construct_begin
t 32         self.s += additiv t 32  
33 # construct_end 33  
34 34
35         return additiv 35         return additiv
36 36
37 def calledRepeatedly(): 37 def calledRepeatedly():
38     # Force frame and eliminate forward propagation (currently). 38     # Force frame and eliminate forward propagation (currently).

Context Diff of Generated Code


Construct
Baseline
559 #endif 559 #endif
560 560
561     // Local variable declarations. 561     // Local variable declarations.
562     PyObject *par_self = python_pars[ 0 ]; 562     PyObject *par_self = python_pars[ 0 ];
563     PyObject *var_additiv = NULL; 563     PyObject *var_additiv = NULL;
n 564     PyObject *tmp_inplace_assign_attr_1__start = NULL; n
565     PyObject *tmp_inplace_assign_attr_1__end = NULL;
566     PyObject *exception_type = NULL, *exception_value = NULL; 564     PyObject *exception_type = NULL, *exception_value = NULL;
567     PyTracebackObject *exception_tb = NULL; 565     PyTracebackObject *exception_tb = NULL;
568     NUITKA_MAY_BE_UNUSED int exception_lineno = -1; 566     NUITKA_MAY_BE_UNUSED int exception_lineno = -1;
569     PyObject *exception_keeper_type_1; 567     PyObject *exception_keeper_type_1;
570     PyObject *exception_keeper_value_1; 568     PyObject *exception_keeper_value_1;
571     PyTracebackObject *exception_keeper_tb_1; 569     PyTracebackObject *exception_keeper_tb_1;
572     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 570     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
n 573     PyObject *exception_keeper_type_2; n
574     PyObject *exception_keeper_value_2;
575     PyTracebackObject *exception_keeper_tb_2;
576     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_2;
577     PyObject *exception_keeper_type_3;
578     PyObject *exception_keeper_value_3;
579     PyTracebackObject *exception_keeper_tb_3;
580     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_3;
581     PyObject *tmp_assattr_name_1;
582     PyObject *tmp_assattr_target_1;
583     PyObject *tmp_assign_source_1; 571     PyObject *tmp_assign_source_1;
n 584     PyObject *tmp_assign_source_2; n
585     PyObject *tmp_assign_source_3;
586     PyObject *tmp_compare_left_1;
587     PyObject *tmp_compare_right_1;
588     bool tmp_isnot_1;
589     PyObject *tmp_left_name_1; 572     PyObject *tmp_left_name_1;
n 590     PyObject *tmp_left_name_2; n
591     bool tmp_result;
592     PyObject *tmp_return_value; 573     PyObject *tmp_return_value;
593     PyObject *tmp_right_name_1; 574     PyObject *tmp_right_name_1;
n 594     PyObject *tmp_right_name_2; n
595     PyObject *tmp_source_name_1;
596     static struct Nuitka_FrameObject *cache_frame_function = NULL; 575     static struct Nuitka_FrameObject *cache_frame_function = NULL;
597 576
598     struct Nuitka_FrameObject *frame_function; 577     struct Nuitka_FrameObject *frame_function;
599 578
600     char const *type_description; 579     char const *type_description;
627         goto frame_exception_exit_1; 606         goto frame_exception_exit_1;
628     } 607     }
629     assert( var_additiv == NULL ); 608     assert( var_additiv == NULL );
630     var_additiv = tmp_assign_source_1; 609     var_additiv = tmp_assign_source_1;
631 610
n 632     tmp_source_name_1 = par_self; n
633 611
n 634     tmp_assign_source_2 = LOOKUP_ATTRIBUTE( tmp_source_name_1, const_str_plain_s ); n 612 #if 0
635     if ( tmp_assign_source_2 == NULL ) 613     RESTORE_FRAME_EXCEPTION( frame_function );
636     { 614 #endif
637         assert( ERROR_OCCURRED() );
638 615
n 639         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb ); n 616     // Put the previous frame back on top.
617     popFrameStack();
640 618
n n 619     goto frame_no_exception_1;
641 620
n 642         exception_lineno = 32; n
643         type_description = "oo";
644         goto frame_exception_exit_1; 621     frame_exception_exit_1:;
645     }
646     assert( tmp_inplace_assign_attr_1__start == NULL );
647     tmp_inplace_assign_attr_1__start = tmp_assign_source_2;
648 622
n 649     // Tried code: n 623 #if 0
650     tmp_left_name_2 = tmp_inplace_assign_attr_1__start; 624     RESTORE_FRAME_EXCEPTION( frame_function );
625 #endif
651 626
n 652     tmp_right_name_2 = var_additiv; n
653  
654     if ( tmp_right_name_2 == NULL )
655     {
656  
657         exception_type = PyExc_UnboundLocalError;
658         Py_INCREF( exception_type );
659         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "additiv" );
660         exception_tb = NULL; 627     if ( exception_tb == NULL )
661         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 628     {
662         CHAIN_EXCEPTION( exception_value ); 629         exception_tb = MAKE_TRACEBACK( frame_function, exception_lineno );
630     }
631     else if ( exception_tb->tb_frame != &frame_function->m_frame )
632     {
633         exception_tb = ADD_TRACEBACK( exception_tb, frame_function, exception_lineno );
634     }
663 635
n 664         exception_lineno = 32; n 636     Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)frame_function, type_description ,par_self, var_additiv );
665         type_description = "oo"; 637  
638     // Release cached frame.
639     if ( frame_function == cache_frame_function )
640     {
641         Py_DECREF( frame_function );
642     }
643     cache_frame_function = NULL;
644  
645     assertFrameObject( frame_function );
646  
647  
648     // Put the previous frame back on top.
649     popFrameStack();
650  
651     // Return the error.
666         goto try_except_handler_2; 652     goto try_except_handler_1;
667     }
668 653
n 669     tmp_assign_source_3 = BINARY_OPERATION( PyNumber_InPlaceAdd, tmp_left_name_2, tmp_right_name_2 ); n 654     frame_no_exception_1:;
670     if ( tmp_assign_source_3 == NULL )
671     {
672         assert( ERROR_OCCURRED() );
673 655
n 674         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb ); n 656     tmp_return_value = var_additiv;
675 657
n 676   n 658     Py_INCREF( tmp_return_value );
677         exception_lineno = 32;
678         type_description = "oo";
679         goto try_except_handler_2; 659     goto try_return_handler_1;
680     } 660     // tried codes exits in all cases
681     assert( tmp_inplace_assign_attr_1__end == NULL ); 661     NUITKA_CANNOT_GET_HERE( __main__$$$class_1_C$$$function_2_increment );
682     tmp_inplace_assign_attr_1__end = tmp_assign_source_3; 662     return NULL;
663     // Return handler code:
664     try_return_handler_1:;
665     CHECK_OBJECT( (PyObject *)par_self );
666     Py_DECREF( par_self );
667     par_self = NULL;
683 668
n 684     // Tried code: n 669     Py_XDECREF( var_additiv );
685     tmp_compare_left_1 = tmp_inplace_assign_attr_1__start; 670     var_additiv = NULL;
686 671
n 687     tmp_compare_right_1 = tmp_inplace_assign_attr_1__end; n 672     goto function_return_exit;
688  
689     tmp_isnot_1 = ( tmp_compare_left_1 != tmp_compare_right_1 );
690     if ( tmp_isnot_1 )
691     {
692         goto branch_yes_1;
693     }
694     else
695     {
696         goto branch_no_1;
697     }
698     branch_yes_1:;
699     tmp_assattr_name_1 = tmp_inplace_assign_attr_1__end;
700  
701     tmp_assattr_target_1 = par_self;
702  
703     if ( tmp_assattr_target_1 == NULL )
704     {
705  
706         exception_type = PyExc_UnboundLocalError;
707         Py_INCREF( exception_type );
708         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "self" );
709         exception_tb = NULL;
710         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
711         CHAIN_EXCEPTION( exception_value );
712  
713         exception_lineno = 32;
714         type_description = "oo";
715         goto try_except_handler_3;
716     }
717  
718     tmp_result = SET_ATTRIBUTE( tmp_assattr_target_1, const_str_plain_s, tmp_assattr_name_1 );
719     if ( tmp_result == false )
720     {
721         assert( ERROR_OCCURRED() );
722  
723         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
724  
725  
726         exception_lineno = 32;
727         type_description = "oo";
728         goto try_except_handler_3;
729     }
730     branch_no_1:;
731     goto try_end_1;
732     // Exception handler code: 673     // Exception handler code:
n 733     try_except_handler_3:; n 674     try_except_handler_1:;
734     exception_keeper_type_1 = exception_type; 675     exception_keeper_type_1 = exception_type;
735     exception_keeper_value_1 = exception_value; 676     exception_keeper_value_1 = exception_value;
736     exception_keeper_tb_1 = exception_tb; 677     exception_keeper_tb_1 = exception_tb;
737     exception_keeper_lineno_1 = exception_lineno; 678     exception_keeper_lineno_1 = exception_lineno;
738     exception_type = NULL; 679     exception_type = NULL;
739     exception_value = NULL; 680     exception_value = NULL;
740     exception_tb = NULL; 681     exception_tb = NULL;
741     exception_lineno = -1; 682     exception_lineno = -1;
742 683
n 743     Py_XDECREF( tmp_inplace_assign_attr_1__end ); n 684     CHECK_OBJECT( (PyObject *)par_self );
744     tmp_inplace_assign_attr_1__end = NULL; 685     Py_DECREF( par_self );
686     par_self = NULL;
745 687
746     // Re-raise. 688     // Re-raise.
747     exception_type = exception_keeper_type_1; 689     exception_type = exception_keeper_type_1;
748     exception_value = exception_keeper_value_1; 690     exception_value = exception_keeper_value_1;
749     exception_tb = exception_keeper_tb_1; 691     exception_tb = exception_keeper_tb_1;
750     exception_lineno = exception_keeper_lineno_1; 692     exception_lineno = exception_keeper_lineno_1;
t 751   t
752     goto try_except_handler_2;
753     // End of try:
754     try_end_1:;
755     goto try_end_2;
756     // Exception handler code:
757     try_except_handler_2:;
758     exception_keeper_type_2 = exception_type;
759     exception_keeper_value_2 = exception_value;
760     exception_keeper_tb_2 = exception_tb;
761     exception_keeper_lineno_2 = exception_lineno;
762     exception_type = NULL;
763     exception_value = NULL;
764     exception_tb = NULL;
765     exception_lineno = -1;
766  
767     Py_XDECREF( tmp_inplace_assign_attr_1__start );
768     tmp_inplace_assign_attr_1__start = NULL;
769  
770     // Re-raise.
771     exception_type = exception_keeper_type_2;
772     exception_value = exception_keeper_value_2;
773     exception_tb = exception_keeper_tb_2;
774     exception_lineno = exception_keeper_lineno_2;
775  
776     goto frame_exception_exit_1;
777     // End of try:
778     try_end_2:;
779     Py_XDECREF( tmp_inplace_assign_attr_1__end );
780     tmp_inplace_assign_attr_1__end = NULL;
781  
782     Py_XDECREF( tmp_inplace_assign_attr_1__start );
783     tmp_inplace_assign_attr_1__start = NULL;
784  
785     tmp_return_value = var_additiv;
786  
787     if ( tmp_return_value == NULL )
788     {
789  
790         exception_type = PyExc_UnboundLocalError;
791         Py_INCREF( exception_type );
792         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "additiv" );
793         exception_tb = NULL;
794         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
795         CHAIN_EXCEPTION( exception_value );
796  
797         exception_lineno = 35;
798         type_description = "oo";
799         goto frame_exception_exit_1;
800     }
801  
802     Py_INCREF( tmp_return_value );
803     goto frame_return_exit_1;
804  
805 #if 0
806     RESTORE_FRAME_EXCEPTION( frame_function );
807 #endif
808  
809     // Put the previous frame back on top.
810     popFrameStack();
811  
812     goto frame_no_exception_1;
813  
814     frame_return_exit_1:;
815 #if 0
816     RESTORE_FRAME_EXCEPTION( frame_function );
817 #endif
818  
819     // Put the previous frame back on top.
820     popFrameStack();
821  
822     goto try_return_handler_1;
823  
824     frame_exception_exit_1:;
825  
826 #if 0
827     RESTORE_FRAME_EXCEPTION( frame_function );
828 #endif
829  
830     if ( exception_tb == NULL )
831     {
832         exception_tb = MAKE_TRACEBACK( frame_function, exception_lineno );
833     }
834     else if ( exception_tb->tb_frame != &frame_function->m_frame )
835     {
836         exception_tb = ADD_TRACEBACK( exception_tb, frame_function, exception_lineno );
837     }
838  
839     Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)frame_function, type_description ,par_self, var_additiv );
840  
841     // Release cached frame.
842     if ( frame_function == cache_frame_function )
843     {
844         Py_DECREF( frame_function );
845     }
846     cache_frame_function = NULL;
847  
848     assertFrameObject( frame_function );
849  
850  
851     // Put the previous frame back on top.
852     popFrameStack();
853  
854     // Return the error.
855     goto try_except_handler_1;
856  
857     frame_no_exception_1:;
858  
859     // tried codes exits in all cases
860     NUITKA_CANNOT_GET_HERE( __main__$$$class_1_C$$$function_2_increment );
861     return NULL;
862     // Return handler code:
863     try_return_handler_1:;
864     Py_XDECREF( par_self );
865     par_self = NULL;
866  
867     Py_XDECREF( var_additiv );
868     var_additiv = NULL;
869  
870     goto function_return_exit;
871     // Exception handler code:
872     try_except_handler_1:;
873     exception_keeper_type_3 = exception_type;
874     exception_keeper_value_3 = exception_value;
875     exception_keeper_tb_3 = exception_tb;
876     exception_keeper_lineno_3 = exception_lineno;
877     exception_type = NULL;
878     exception_value = NULL;
879     exception_tb = NULL;
880     exception_lineno = -1;
881  
882     Py_XDECREF( par_self );
883     par_self = NULL;
884  
885     Py_XDECREF( var_additiv );
886     var_additiv = NULL;
887  
888     // Re-raise.
889     exception_type = exception_keeper_type_3;
890     exception_value = exception_keeper_value_3;
891     exception_tb = exception_keeper_tb_3;
892     exception_lineno = exception_keeper_lineno_3;
893 693
894     goto function_exception_exit; 694     goto function_exception_exit;
895     // End of try: 695     // End of try:
896 696
897     // Return statement must have exited already. 697     // Return statement must have exited already.