Construct InplaceOperationInstanceStringAdd

Performance Diagrams

Construct InplaceOperationInstanceStringAdd 001000000001000000002000000002000000003000000003000000004000000004000000005000000005000000006000000006000000007000000007000000008000000008000000009000000009000000001000000000100000000011000000001100000000120000000012000000001300000000130000000014000000001400000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)143084968672.23076923076923257.0CPython 2.71420700532192.61538461538458258.7528131143126Nuitka (historic)1417300766313.0259.3399708646427Nuitka (master)1417251211433.38461538461536259.3485292778739Nuitka (develop)1417251388553.7692307692307259.3484987090284Nuitka (factory)Construct InplaceOperationInstanceStringAddTicks Construct InplaceOperationInstanceStringAdd 001000000001000000002000000002000000003000000003000000004000000004000000005000000005000000006000000006000000007000000007000000008000000008000000009000000009000000001000000000100000000011000000001100000000120000000012000000001300000000130000000014000000001400000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)144968386672.23076923076923257.14269343780313CPython 3.50192.61538461538458504.11538461538464Nuitka (historic)1450521450313.0257.0Nuitka (master)1444425480433.38461538461536258.0385285727101Nuitka (develop)1444451550553.7692307692307258.03408720572656Nuitka (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
700 #endif 700 #endif
701 701
702     // Local variable declarations. 702     // Local variable declarations.
703     PyObject *par_self = python_pars[ 0 ]; 703     PyObject *par_self = python_pars[ 0 ];
704     PyObject *var_additiv = NULL; 704     PyObject *var_additiv = NULL;
n 705     PyObject *tmp_inplace_assign_attr_1__start = NULL; n
706     PyObject *tmp_inplace_assign_attr_1__end = NULL;
707     PyObject *exception_type = NULL, *exception_value = NULL; 705     PyObject *exception_type = NULL, *exception_value = NULL;
708     PyTracebackObject *exception_tb = NULL; 706     PyTracebackObject *exception_tb = NULL;
709     NUITKA_MAY_BE_UNUSED int exception_lineno = -1; 707     NUITKA_MAY_BE_UNUSED int exception_lineno = -1;
710     PyObject *exception_keeper_type_1; 708     PyObject *exception_keeper_type_1;
711     PyObject *exception_keeper_value_1; 709     PyObject *exception_keeper_value_1;
712     PyTracebackObject *exception_keeper_tb_1; 710     PyTracebackObject *exception_keeper_tb_1;
713     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 711     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
n 714     PyObject *exception_keeper_type_2; n
715     PyObject *exception_keeper_value_2;
716     PyTracebackObject *exception_keeper_tb_2;
717     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_2;
718     PyObject *exception_keeper_type_3;
719     PyObject *exception_keeper_value_3;
720     PyTracebackObject *exception_keeper_tb_3;
721     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_3;
722     PyObject *tmp_assattr_name_1;
723     PyObject *tmp_assattr_target_1;
724     PyObject *tmp_assign_source_1; 712     PyObject *tmp_assign_source_1;
n 725     PyObject *tmp_assign_source_2; n
726     PyObject *tmp_assign_source_3;
727     PyObject *tmp_compare_left_1;
728     PyObject *tmp_compare_right_1;
729     bool tmp_isnot_1;
730     PyObject *tmp_left_name_1; 713     PyObject *tmp_left_name_1;
n 731     PyObject *tmp_left_name_2; n
732     bool tmp_result;
733     PyObject *tmp_return_value; 714     PyObject *tmp_return_value;
734     PyObject *tmp_right_name_1; 715     PyObject *tmp_right_name_1;
n 735     PyObject *tmp_right_name_2; n
736     PyObject *tmp_source_name_1;
737     static struct Nuitka_FrameObject *cache_frame_b8d32cb433612507b4c9ed5009fd7338 = NULL; 716     static struct Nuitka_FrameObject *cache_frame_b8d32cb433612507b4c9ed5009fd7338 = NULL;
738 717
739     struct Nuitka_FrameObject *frame_b8d32cb433612507b4c9ed5009fd7338; 718     struct Nuitka_FrameObject *frame_b8d32cb433612507b4c9ed5009fd7338;
740 719
741     char const *type_description; 720     char const *type_description;
768         goto frame_exception_exit_1; 747         goto frame_exception_exit_1;
769     } 748     }
770     assert( var_additiv == NULL ); 749     assert( var_additiv == NULL );
771     var_additiv = tmp_assign_source_1; 750     var_additiv = tmp_assign_source_1;
772 751
n 773     tmp_source_name_1 = par_self; n
774 752
n 775     CHECK_OBJECT( tmp_source_name_1 ); n 753 #if 0
776     tmp_assign_source_2 = LOOKUP_ATTRIBUTE( tmp_source_name_1, const_str_plain_s ); 754     RESTORE_FRAME_EXCEPTION( frame_b8d32cb433612507b4c9ed5009fd7338 );
777     if ( tmp_assign_source_2 == NULL ) 755 #endif
778     {
779         assert( ERROR_OCCURRED() );
780 756
n 781         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb ); n 757     // Put the previous frame back on top.
758     popFrameStack();
782 759
n n 760     goto frame_no_exception_1;
783 761
n 784         exception_lineno = 32; n
785         type_description = "oo";
786         goto frame_exception_exit_1; 762     frame_exception_exit_1:;
787     }
788     assert( tmp_inplace_assign_attr_1__start == NULL );
789     tmp_inplace_assign_attr_1__start = tmp_assign_source_2;
790 763
n 791     // Tried code: n 764 #if 0
792     tmp_left_name_2 = tmp_inplace_assign_attr_1__start; 765     RESTORE_FRAME_EXCEPTION( frame_b8d32cb433612507b4c9ed5009fd7338 );
766 #endif
793 767
n 794     CHECK_OBJECT( tmp_left_name_2 ); n
795     tmp_right_name_2 = var_additiv;
796  
797     if ( tmp_right_name_2 == NULL )
798     {
799  
800         exception_type = PyExc_UnboundLocalError;
801         Py_INCREF( exception_type );
802         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "additiv" );
803         exception_tb = NULL; 768     if ( exception_tb == NULL )
804         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 769     {
805         CHAIN_EXCEPTION( exception_value ); 770         exception_tb = MAKE_TRACEBACK( frame_b8d32cb433612507b4c9ed5009fd7338, exception_lineno );
771     }
772     else if ( exception_tb->tb_frame != &frame_b8d32cb433612507b4c9ed5009fd7338->m_frame )
773     {
774         exception_tb = ADD_TRACEBACK( exception_tb, frame_b8d32cb433612507b4c9ed5009fd7338, exception_lineno );
775     }
806 776
n 807         exception_lineno = 32; n 777     Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)frame_b8d32cb433612507b4c9ed5009fd7338, type_description ,par_self, var_additiv );
808         type_description = "oo"; 778  
779     // Release cached frame.
780     if ( frame_b8d32cb433612507b4c9ed5009fd7338 == cache_frame_b8d32cb433612507b4c9ed5009fd7338 )
781     {
782         Py_DECREF( frame_b8d32cb433612507b4c9ed5009fd7338 );
783     }
784     cache_frame_b8d32cb433612507b4c9ed5009fd7338 = NULL;
785  
786     assertFrameObject( frame_b8d32cb433612507b4c9ed5009fd7338 );
787  
788  
789     // Put the previous frame back on top.
790     popFrameStack();
791  
792     // Return the error.
809         goto try_except_handler_2; 793     goto try_except_handler_1;
810     }
811 794
n 812     tmp_assign_source_3 = BINARY_OPERATION( PyNumber_InPlaceAdd, tmp_left_name_2, tmp_right_name_2 ); n 795     frame_no_exception_1:;
813     if ( tmp_assign_source_3 == NULL )
814     {
815         assert( ERROR_OCCURRED() );
816 796
n 817         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb ); n 797     tmp_return_value = var_additiv;
818 798
n 819   n
820         exception_lineno = 32;
821         type_description = "oo";
822         goto try_except_handler_2;
823     }
824     assert( tmp_inplace_assign_attr_1__end == NULL );
825     tmp_inplace_assign_attr_1__end = tmp_assign_source_3;
826  
827     // Tried code:
828     tmp_compare_left_1 = tmp_inplace_assign_attr_1__start;
829  
830     CHECK_OBJECT( tmp_compare_left_1 ); 799     CHECK_OBJECT( tmp_return_value );
831     tmp_compare_right_1 = tmp_inplace_assign_attr_1__end; 800     Py_INCREF( tmp_return_value );
832  
833     CHECK_OBJECT( tmp_compare_right_1 );
834     tmp_isnot_1 = ( tmp_compare_left_1 != tmp_compare_right_1 );
835     if ( tmp_isnot_1 )
836     {
837         goto branch_yes_1;
838     }
839     else
840     {
841         goto branch_no_1;
842     }
843     branch_yes_1:;
844     tmp_assattr_name_1 = tmp_inplace_assign_attr_1__end;
845  
846     CHECK_OBJECT( tmp_assattr_name_1 );
847     tmp_assattr_target_1 = par_self;
848  
849     if ( tmp_assattr_target_1 == NULL )
850     {
851  
852         exception_type = PyExc_UnboundLocalError;
853         Py_INCREF( exception_type );
854         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "self" );
855         exception_tb = NULL;
856         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
857         CHAIN_EXCEPTION( exception_value );
858  
859         exception_lineno = 32;
860         type_description = "oo";
861         goto try_except_handler_3; 801     goto try_return_handler_1;
862     } 802     // tried codes exits in all cases
803     NUITKA_CANNOT_GET_HERE( __main__$$$class_1_C$$$function_2_increment );
804     return NULL;
805     // Return handler code:
806     try_return_handler_1:;
807     CHECK_OBJECT( (PyObject *)par_self );
808     Py_DECREF( par_self );
809     par_self = NULL;
863 810
n 864     tmp_result = SET_ATTRIBUTE( tmp_assattr_target_1, const_str_plain_s, tmp_assattr_name_1 ); n 811     Py_XDECREF( var_additiv );
865     if ( tmp_result == false ) 812     var_additiv = NULL;
866     {
867         assert( ERROR_OCCURRED() );
868 813
n 869         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb ); n 814     goto function_return_exit;
870  
871  
872         exception_lineno = 32;
873         type_description = "oo";
874         goto try_except_handler_3;
875     }
876     branch_no_1:;
877     goto try_end_1;
878     // Exception handler code: 815     // Exception handler code:
n 879     try_except_handler_3:; n 816     try_except_handler_1:;
880     exception_keeper_type_1 = exception_type; 817     exception_keeper_type_1 = exception_type;
881     exception_keeper_value_1 = exception_value; 818     exception_keeper_value_1 = exception_value;
882     exception_keeper_tb_1 = exception_tb; 819     exception_keeper_tb_1 = exception_tb;
883     exception_keeper_lineno_1 = exception_lineno; 820     exception_keeper_lineno_1 = exception_lineno;
884     exception_type = NULL; 821     exception_type = NULL;
885     exception_value = NULL; 822     exception_value = NULL;
886     exception_tb = NULL; 823     exception_tb = NULL;
887     exception_lineno = -1; 824     exception_lineno = -1;
888 825
n 889     Py_XDECREF( tmp_inplace_assign_attr_1__end ); n 826     CHECK_OBJECT( (PyObject *)par_self );
890     tmp_inplace_assign_attr_1__end = NULL; 827     Py_DECREF( par_self );
828     par_self = NULL;
891 829
892     // Re-raise. 830     // Re-raise.
893     exception_type = exception_keeper_type_1; 831     exception_type = exception_keeper_type_1;
894     exception_value = exception_keeper_value_1; 832     exception_value = exception_keeper_value_1;
895     exception_tb = exception_keeper_tb_1; 833     exception_tb = exception_keeper_tb_1;
896     exception_lineno = exception_keeper_lineno_1; 834     exception_lineno = exception_keeper_lineno_1;
t 897   t
898     goto try_except_handler_2;
899     // End of try:
900     try_end_1:;
901     goto try_end_2;
902     // Exception handler code:
903     try_except_handler_2:;
904     exception_keeper_type_2 = exception_type;
905     exception_keeper_value_2 = exception_value;
906     exception_keeper_tb_2 = exception_tb;
907     exception_keeper_lineno_2 = exception_lineno;
908     exception_type = NULL;
909     exception_value = NULL;
910     exception_tb = NULL;
911     exception_lineno = -1;
912  
913     Py_XDECREF( tmp_inplace_assign_attr_1__start );
914     tmp_inplace_assign_attr_1__start = NULL;
915  
916     // Re-raise.
917     exception_type = exception_keeper_type_2;
918     exception_value = exception_keeper_value_2;
919     exception_tb = exception_keeper_tb_2;
920     exception_lineno = exception_keeper_lineno_2;
921  
922     goto frame_exception_exit_1;
923     // End of try:
924     try_end_2:;
925     Py_XDECREF( tmp_inplace_assign_attr_1__end );
926     tmp_inplace_assign_attr_1__end = NULL;
927  
928     Py_XDECREF( tmp_inplace_assign_attr_1__start );
929     tmp_inplace_assign_attr_1__start = NULL;
930  
931     tmp_return_value = var_additiv;
932  
933     if ( tmp_return_value == NULL )
934     {
935  
936         exception_type = PyExc_UnboundLocalError;
937         Py_INCREF( exception_type );
938         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "additiv" );
939         exception_tb = NULL;
940         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
941         CHAIN_EXCEPTION( exception_value );
942  
943         exception_lineno = 35;
944         type_description = "oo";
945         goto frame_exception_exit_1;
946     }
947  
948     Py_INCREF( tmp_return_value );
949     goto frame_return_exit_1;
950  
951 #if 0
952     RESTORE_FRAME_EXCEPTION( frame_b8d32cb433612507b4c9ed5009fd7338 );
953 #endif
954  
955     // Put the previous frame back on top.
956     popFrameStack();
957  
958     goto frame_no_exception_1;
959  
960     frame_return_exit_1:;
961 #if 0
962     RESTORE_FRAME_EXCEPTION( frame_b8d32cb433612507b4c9ed5009fd7338 );
963 #endif
964  
965     // Put the previous frame back on top.
966     popFrameStack();
967  
968     goto try_return_handler_1;
969  
970     frame_exception_exit_1:;
971  
972 #if 0
973     RESTORE_FRAME_EXCEPTION( frame_b8d32cb433612507b4c9ed5009fd7338 );
974 #endif
975  
976     if ( exception_tb == NULL )
977     {
978         exception_tb = MAKE_TRACEBACK( frame_b8d32cb433612507b4c9ed5009fd7338, exception_lineno );
979     }
980     else if ( exception_tb->tb_frame != &frame_b8d32cb433612507b4c9ed5009fd7338->m_frame )
981     {
982         exception_tb = ADD_TRACEBACK( exception_tb, frame_b8d32cb433612507b4c9ed5009fd7338, exception_lineno );
983     }
984  
985     Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)frame_b8d32cb433612507b4c9ed5009fd7338, type_description ,par_self, var_additiv );
986  
987     // Release cached frame.
988     if ( frame_b8d32cb433612507b4c9ed5009fd7338 == cache_frame_b8d32cb433612507b4c9ed5009fd7338 )
989     {
990         Py_DECREF( frame_b8d32cb433612507b4c9ed5009fd7338 );
991     }
992     cache_frame_b8d32cb433612507b4c9ed5009fd7338 = NULL;
993  
994     assertFrameObject( frame_b8d32cb433612507b4c9ed5009fd7338 );
995  
996  
997     // Put the previous frame back on top.
998     popFrameStack();
999  
1000     // Return the error.
1001     goto try_except_handler_1;
1002  
1003     frame_no_exception_1:;
1004  
1005     // tried codes exits in all cases
1006     NUITKA_CANNOT_GET_HERE( __main__$$$class_1_C$$$function_2_increment );
1007     return NULL;
1008     // Return handler code:
1009     try_return_handler_1:;
1010     Py_XDECREF( par_self );
1011     par_self = NULL;
1012  
1013     Py_XDECREF( var_additiv );
1014     var_additiv = NULL;
1015  
1016     goto function_return_exit;
1017     // Exception handler code:
1018     try_except_handler_1:;
1019     exception_keeper_type_3 = exception_type;
1020     exception_keeper_value_3 = exception_value;
1021     exception_keeper_tb_3 = exception_tb;
1022     exception_keeper_lineno_3 = exception_lineno;
1023     exception_type = NULL;
1024     exception_value = NULL;
1025     exception_tb = NULL;
1026     exception_lineno = -1;
1027  
1028     Py_XDECREF( par_self );
1029     par_self = NULL;
1030  
1031     Py_XDECREF( var_additiv );
1032     var_additiv = NULL;
1033  
1034     // Re-raise.
1035     exception_type = exception_keeper_type_3;
1036     exception_value = exception_keeper_value_3;
1037     exception_tb = exception_keeper_tb_3;
1038     exception_lineno = exception_keeper_lineno_3;
1039 835
1040     goto function_exception_exit; 836     goto function_exception_exit;
1041     // End of try: 837     // End of try:
1042 838
1043     // Return statement must have exited already. 839     // Return statement must have exited already.