Construct RichComparisonConditionStrings

Performance Diagrams

Construct RichComparisonConditionStrings 00200000020000004000000400000060000006000000800000080000001000000010000000120000001200000014000000140000001600000016000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)1721972688.95192307692307257.0CPython 2.78450110242.31730769230768382.85026212201234Nuitka (master)8450086395.6826923076923382.8506065391785Nuitka (develop)8450050549.0480769230769382.8511231649277Nuitka (factory)Construct RichComparisonConditionStringsTicks Construct RichComparisonConditionStrings 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000260000002600000028000000280000003000000030000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)3007420988.95192307692307257.0CPython 3.520900468242.31730769230768332.37929046037164Nuitka (master)20895206395.6826923076923332.4225275461366Nuitka (develop)20895298549.0480769230769332.4217715955683Nuitka (factory)Construct RichComparisonConditionStringsTicks

Source Code with Construct

module_value1 = "1000"
module_value2 = "2000"

import sys
loop_count = 50000 if len(sys.argv) < 2 else int(sys.argv[1])

x = 0
import itertools
for _x in itertools.repeat(None, loop_count):
    x += 1
    y = x % 2 == 0

# construct_begin
    if x % 2 == 0:
# construct_alternative


        y = not y

print("OK.")

Source Code without Construct

module_value1 = "1000"
module_value2 = "2000"

import sys
loop_count = 50000 if len(sys.argv) < 2 else int(sys.argv[1])

x = 0
import itertools
for _x in itertools.repeat(None, loop_count):
    x += 1
    y = x % 2 == 0

# construct_begin

# construct_alternative
    if y:
# construct_end
        y = not y

print("OK.")

Context Diff of Source Code


Construct
Baseline
28 for _x in itertools.repeat(None, loop_count): 28 for _x in itertools.repeat(None, loop_count):
29     x += 1 29     x += 1
30     y = x % 2 == 0 30     y = x % 2 == 0
31 31
32 # construct_begin 32 # construct_begin
n 33     if x % 2 == 0: n 33  
34 # construct_alternative 34 # construct_alternative
t 35   t 35     if y:
36   36 # construct_end
37         y = not y 37         y = not y
38 38
39 print("OK.") 39 print("OK.")
40 40

Context Diff of Generated Code


Construct
Baseline
864         goto try_except_handler_1; 864         goto try_except_handler_1;
865     } 865     }
866     UPDATE_STRING_DICT1( moduledict___main__, (Nuitka_StringObject *)const_str_plain_y, tmp_assign_source_14 ); 866     UPDATE_STRING_DICT1( moduledict___main__, (Nuitka_StringObject *)const_str_plain_y, tmp_assign_source_14 );
867     } 867     }
868     { 868     {
n 869     PyObject *tmp_compare_left_3; n 869     PyObject *tmp_cond_value_1;
870     PyObject *tmp_left_name_3; 870     int tmp_cond_truth_1;
871     PyObject *tmp_right_name_3;
872     PyObject *tmp_compare_right_3;
873     int tmp_cmp_Eq_1;
874     tmp_left_name_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_x ); 871     tmp_cond_value_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_y );
875 872
n 876     if (unlikely( tmp_left_name_3 == NULL )) n 873     if (unlikely( tmp_cond_value_1 == NULL ))
877     { 874     {
n 878         tmp_left_name_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_x ); n 875         tmp_cond_value_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_y );
879     }
880  
881     if ( tmp_left_name_3 == NULL )
882     { 876     }
883 877
n 884         exception_type = PyExc_NameError; n 878     CHECK_OBJECT( tmp_cond_value_1 );
885         Py_INCREF( exception_type ); 879     tmp_cond_truth_1 = CHECK_IF_TRUE( tmp_cond_value_1 );
886         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "x" ); 880     if ( tmp_cond_truth_1 == -1 )
887         exception_tb = NULL; 881     {
882         assert( ERROR_OCCURRED() );
883  
888         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 884         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
889         CHAIN_EXCEPTION( exception_value );
890 885
n n 886  
891         exception_lineno = 33; 887         exception_lineno = 35;
892 888
893         goto try_except_handler_1; 889         goto try_except_handler_1;
894     } 890     }
n 895   n
896     tmp_right_name_3 = const_int_pos_2;
897     tmp_compare_left_3 = BINARY_OPERATION_REMAINDER( tmp_left_name_3, tmp_right_name_3 );
898     if ( tmp_compare_left_3 == NULL )
899     {
900         assert( ERROR_OCCURRED() );
901  
902         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
903  
904  
905         exception_lineno = 33;
906  
907         goto try_except_handler_1;
908     }
909     tmp_compare_right_3 = const_int_0;
910     tmp_cmp_Eq_1 = RICH_COMPARE_BOOL_EQ_NORECURSE( tmp_compare_left_3, tmp_compare_right_3 );
911     Py_DECREF( tmp_compare_left_3 );
912     if ( tmp_cmp_Eq_1 == -1 )
913     {
914         assert( ERROR_OCCURRED() );
915  
916         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
917  
918  
919         exception_lineno = 33;
920  
921         goto try_except_handler_1;
922     }
923     if ( tmp_cmp_Eq_1 == 1 ) 891     if ( tmp_cond_truth_1 == 1 )
924     { 892     {
925         goto branch_yes_2; 893         goto branch_yes_2;
926     } 894     }
927     else 895     else
928     { 896     {
937     if (unlikely( tmp_operand_name_1 == NULL )) 905     if (unlikely( tmp_operand_name_1 == NULL ))
938     { 906     {
939         tmp_operand_name_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_y ); 907         tmp_operand_name_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_y );
940     } 908     }
941 909
t 942     if ( tmp_operand_name_1 == NULL ) t 910     CHECK_OBJECT( tmp_operand_name_1 );
943     {
944  
945         exception_type = PyExc_NameError;
946         Py_INCREF( exception_type );
947         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "y" );
948         exception_tb = NULL;
949         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
950         CHAIN_EXCEPTION( exception_value );
951  
952         exception_lineno = 37;
953  
954         goto try_except_handler_1;
955     }
956  
957     tmp_assign_source_15 = UNARY_OPERATION( UNARY_NOT, tmp_operand_name_1 ); 911     tmp_assign_source_15 = UNARY_OPERATION( UNARY_NOT, tmp_operand_name_1 );
958     if ( tmp_assign_source_15 == NULL ) 912     if ( tmp_assign_source_15 == NULL )
959     { 913     {
960         assert( ERROR_OCCURRED() ); 914         assert( ERROR_OCCURRED() );
961 915