Construct RichComparisonConditionStrings

Performance Diagrams

Construct RichComparisonConditionStrings 00200000020000004000000400000060000006000000800000080000001000000010000000120000001200000014000000140000001600000016000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)1606965988.95192307692307257.0CPython 2.79100006242.31730769230768364.1776620605807Nuitka (master)7999725395.6826923076923381.0975209387311Nuitka (develop)7999701549.0480769230769381.0978900050088Nuitka (factory)Construct RichComparisonConditionStringsTicks Construct RichComparisonConditionStrings 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000260000002600000028000000280000003000000030000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)3014371788.95192307692307257.0CPython 3.521631121242.31730769230768326.7854692112252Nuitka (master)21130914395.6826923076923330.8861196118479Nuitka (develop)21127343549.0480769230769330.9153943372728Nuitka (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
63 63
64 /* Function to create module private constants. */ 64 /* Function to create module private constants. */
65 static void createModuleConstants( void ) 65 static void createModuleConstants( void )
66 { 66 {
67     const_str_plain_loop_count = UNSTREAM_STRING_ASCII( &constant_bin[ 31 ], 10, 1 ); 67     const_str_plain_loop_count = UNSTREAM_STRING_ASCII( &constant_bin[ 31 ], 10, 1 );
n 68     const_str_plain_itertools = UNSTREAM_STRING_ASCII( &constant_bin[ 103 ], 9, 1 ); n 68     const_str_plain_itertools = UNSTREAM_STRING_ASCII( &constant_bin[ 80 ], 9, 1 );
69     const_str_plain_sys = UNSTREAM_STRING_ASCII( &constant_bin[ 6 ], 3, 1 ); 69     const_str_plain_sys = UNSTREAM_STRING_ASCII( &constant_bin[ 6 ], 3, 1 );
70     const_str_plain_y = UNSTREAM_STRING_ASCII( &constant_bin[ 7 ], 1, 1 ); 70     const_str_plain_y = UNSTREAM_STRING_ASCII( &constant_bin[ 7 ], 1, 1 );
n 71     const_str_digest_77643f9c6746e247b55af666dc6d88db = UNSTREAM_STRING_ASCII( &constant_bin[ 112 ], 55, 0 ); n 71     const_str_digest_77643f9c6746e247b55af666dc6d88db = UNSTREAM_STRING_ASCII( &constant_bin[ 89 ], 55, 0 );
72     const_int_pos_50000 = PyLong_FromUnsignedLong(50000ul); 72     const_int_pos_50000 = PyLong_FromUnsignedLong(50000ul);
n 73     const_str_plain_module_value2 = UNSTREAM_STRING_ASCII( &constant_bin[ 167 ], 13, 1 ); n 73     const_str_plain_module_value2 = UNSTREAM_STRING_ASCII( &constant_bin[ 144 ], 13, 1 );
74     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 74     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
n 75     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 180 ], 3, 0 ); n 75     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING_ASCII( &constant_bin[ 157 ], 3, 0 );
76     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF(const_str_digest_5ed1392909ad16e6227b8230f4582352); 76     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF(const_str_digest_5ed1392909ad16e6227b8230f4582352);
n 77     const_str_plain_module_value1 = UNSTREAM_STRING_ASCII( &constant_bin[ 183 ], 13, 1 ); n 77     const_str_plain_module_value1 = UNSTREAM_STRING_ASCII( &constant_bin[ 160 ], 13, 1 );
78     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 196 ], 8, 0 ); 78     const_str_angle_module = UNSTREAM_STRING_ASCII( &constant_bin[ 173 ], 8, 0 );
79     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 63 ], 1, 1 ); 79     const_str_plain_x = UNSTREAM_STRING_ASCII( &constant_bin[ 63 ], 1, 1 );
n 80     const_str_plain_repeat = UNSTREAM_STRING_ASCII( &constant_bin[ 204 ], 6, 1 ); n 80     const_str_plain_repeat = UNSTREAM_STRING_ASCII( &constant_bin[ 181 ], 6, 1 );
81     const_int_pos_2 = PyLong_FromUnsignedLong(2ul); 81     const_int_pos_2 = PyLong_FromUnsignedLong(2ul);
n 82     const_str_plain__x = UNSTREAM_STRING_ASCII( &constant_bin[ 210 ], 2, 1 ); n 82     const_str_plain__x = UNSTREAM_STRING_ASCII( &constant_bin[ 187 ], 2, 1 );
83     const_str_plain_1000 = UNSTREAM_STRING_ASCII( &constant_bin[ 212 ], 4, 0 ); 83     const_str_plain_1000 = UNSTREAM_STRING_ASCII( &constant_bin[ 189 ], 4, 0 );
84     const_str_plain_argv = UNSTREAM_STRING_ASCII( &constant_bin[ 216 ], 4, 1 ); 84     const_str_plain_argv = UNSTREAM_STRING_ASCII( &constant_bin[ 193 ], 4, 1 );
85     const_str_plain_2000 = UNSTREAM_STRING_ASCII( &constant_bin[ 220 ], 4, 0 ); 85     const_str_plain_2000 = UNSTREAM_STRING_ASCII( &constant_bin[ 197 ], 4, 0 );
86 86
87     constants_created = true; 87     constants_created = true;
88 } 88 }
89 89
90 /* Function to verify module private constants for non-corruption. */ 90 /* Function to verify module private constants for non-corruption. */
814         } 814         }
815         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)const_str_plain_y, tmp_assign_source_14); 815         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)const_str_plain_y, tmp_assign_source_14);
816     } 816     }
817     { 817     {
818         nuitka_bool tmp_condition_result_2; 818         nuitka_bool tmp_condition_result_2;
n 819         PyObject *tmp_compexpr_left_3; n
820         PyObject *tmp_compexpr_right_3;
821         PyObject *tmp_left_name_3;
822         PyObject *tmp_mvar_value_7; 819         PyObject *tmp_mvar_value_7;
n 823         PyObject *tmp_right_name_3; n 820         int tmp_truth_name_1;
824         tmp_mvar_value_7 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)const_str_plain_x); 821         tmp_mvar_value_7 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)const_str_plain_y);
825 822
826         if (unlikely( tmp_mvar_value_7 == NULL )) { 823         if (unlikely( tmp_mvar_value_7 == NULL )) {
n 827             tmp_mvar_value_7 = GET_STRING_DICT_VALUE(dict_builtin, (Nuitka_StringObject *)const_str_plain_x); n 824             tmp_mvar_value_7 = GET_STRING_DICT_VALUE(dict_builtin, (Nuitka_StringObject *)const_str_plain_y);
828         }
829  
830         if ( tmp_mvar_value_7 == NULL )
831         { 825         }
832 826
n 833             exception_type = PyExc_NameError; n 827         CHECK_OBJECT(tmp_mvar_value_7);
834             Py_INCREF(exception_type); 828         tmp_truth_name_1 = CHECK_IF_TRUE( tmp_mvar_value_7 );
835             exception_value = UNSTREAM_STRING( &constant_bin[ 57 ], 23, 0 ); 829         if ( tmp_truth_name_1 == -1 )
836             exception_tb = NULL; 830         {
831             assert(ERROR_OCCURRED());
832  
837             NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb ); 833             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
838             CHAIN_EXCEPTION( exception_value );
839 834
n n 835  
840             exception_lineno = 33; 836             exception_lineno = 35;
841 837
842             goto try_except_handler_1; 838             goto try_except_handler_1;
843         } 839         }
n 844   n
845         tmp_left_name_3 = tmp_mvar_value_7;
846         tmp_right_name_3 = const_int_pos_2;
847         tmp_compexpr_left_3 = BINARY_OPERATION_MOD_OBJECT_LONG( tmp_left_name_3, tmp_right_name_3 );
848         if ( tmp_compexpr_left_3 == NULL )
849         {
850             assert(ERROR_OCCURRED());
851  
852             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
853  
854  
855             exception_lineno = 33;
856  
857             goto try_except_handler_1;
858         }
859         tmp_compexpr_right_3 = const_int_0;
860         tmp_res = RICH_COMPARE_BOOL_EQ_OBJECT_OBJECT_NORECURSE( tmp_compexpr_left_3, tmp_compexpr_right_3 );
861         Py_DECREF(tmp_compexpr_left_3);
862         if ( tmp_res == -1 )
863         {
864             assert(ERROR_OCCURRED());
865  
866             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
867  
868  
869             exception_lineno = 33;
870  
871             goto try_except_handler_1;
872         }
873         tmp_condition_result_2 = ( tmp_res != 0 ) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE; 840         tmp_condition_result_2 = tmp_truth_name_1 == 1 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
874         if (tmp_condition_result_2 == NUITKA_BOOL_TRUE) 841         if (tmp_condition_result_2 == NUITKA_BOOL_TRUE)
875         { 842         {
876             goto branch_yes_1; 843             goto branch_yes_1;
877         } else { 844         } else {
878             goto branch_no_1; 845             goto branch_no_1;
886 853
887             if (unlikely( tmp_mvar_value_8 == NULL )) { 854             if (unlikely( tmp_mvar_value_8 == NULL )) {
888                 tmp_mvar_value_8 = GET_STRING_DICT_VALUE(dict_builtin, (Nuitka_StringObject *)const_str_plain_y); 855                 tmp_mvar_value_8 = GET_STRING_DICT_VALUE(dict_builtin, (Nuitka_StringObject *)const_str_plain_y);
889             } 856             }
890 857
t 891             if ( tmp_mvar_value_8 == NULL ) t 858             CHECK_OBJECT(tmp_mvar_value_8);
892             {
893  
894                 exception_type = PyExc_NameError;
895                 Py_INCREF(exception_type);
896                 exception_value = UNSTREAM_STRING( &constant_bin[ 80 ], 23, 0 );
897                 exception_tb = NULL;
898                 NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
899                 CHAIN_EXCEPTION( exception_value );
900  
901                 exception_lineno = 37;
902  
903                 goto try_except_handler_1;
904             }
905  
906             tmp_operand_name_1 = tmp_mvar_value_8; 859             tmp_operand_name_1 = tmp_mvar_value_8;
907             tmp_res = CHECK_IF_TRUE( tmp_operand_name_1 ); 860             tmp_res = CHECK_IF_TRUE( tmp_operand_name_1 );
908             if ( tmp_res == -1 ) 861             if ( tmp_res == -1 )
909             { 862             {
910                 assert(ERROR_OCCURRED()); 863                 assert(ERROR_OCCURRED());