Construct RichComparisonStrings

Performance Diagrams

Construct RichComparisonStrings 00100000010000002000000200000030000003000000400000040000005000000500000060000006000000700000070000008000000800000090000009000000100000001000000011000000110000001200000012000000CPython 3.10Nuitka (main)Nuitka (develop)Nuitka (factory)1219773888.95192307692307257.0CPython 3.107150231242.31730769230768359.258027976486Nuitka (main)7150231395.6826923076923359.258027976486Nuitka (develop)7150231549.0480769230769359.258027976486Nuitka (factory)Construct RichComparisonStringsTicks Construct RichComparisonStrings 00100000010000002000000200000030000003000000400000040000005000000500000060000006000000700000070000008000000800000090000009000000100000001000000011000000110000001200000012000000CPython 3.8Nuitka (main)Nuitka (develop)Nuitka (factory)1218040088.95192307692307257.0CPython 3.87100144242.31730769230768360.067995746003Nuitka (main)7100144395.6826923076923360.067995746003Nuitka (develop)7100144549.0480769230769360.067995746003Nuitka (factory)Construct RichComparisonStringsTicks Construct RichComparisonStrings 001000000100000020000002000000300000030000004000000400000050000005000000600000060000007000000700000080000008000000900000090000001000000010000000CPython 2.7Nuitka (main)Nuitka (develop)Nuitka (factory)1073613488.95192307692307257.0CPython 2.74550000242.31730769230768399.38727671360175Nuitka (main)4550000395.6826923076923399.38727671360175Nuitka (develop)4550000549.0480769230769399.38727671360175Nuitka (factory)Construct RichComparisonStringsTicks

Source Code with Construct

import itertools
import sys

module_value1 = "1000"
module_value2 = "2000"

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


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

    # construct_begin
    if value1 == value2:
        return
    # construct_end

    return value1, value2


for x in itertools.repeat(None, 50000):
    calledRepeatedly(module_value1, module_value2)

print("OK.")

Source Code without Construct

import itertools
import sys

module_value1 = "1000"
module_value2 = "2000"

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


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

    # construct_begin




    return value1, value2


for x in itertools.repeat(None, 50000):
    calledRepeatedly(module_value1, module_value2)

print("OK.")

Context Diff of Source Code


Construct
Baseline
29 def calledRepeatedly(value1, value2): 29 def calledRepeatedly(value1, value2):
30     # Force frame and eliminate forward propagation (currently). 30     # Force frame and eliminate forward propagation (currently).
31     module_value1 31     module_value1
32 32
33     # construct_begin 33     # construct_begin
t 34     if value1 == value2: t 34  
35         return 35  
36     # construct_end 36  
37 37
38     return value1, value2 38     return value1, value2
39 39
40 40
41 for x in itertools.repeat(None, 50000): 41 for x in itertools.repeat(None, 50000):

Context Diff of Generated Code


Construct
Baseline
109     NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused; 109     NUITKA_MAY_BE_UNUSED nuitka_void tmp_unused;
110     PyObject *exception_type = NULL; 110     PyObject *exception_type = NULL;
111     PyObject *exception_value = NULL; 111     PyObject *exception_value = NULL;
112     PyTracebackObject *exception_tb = NULL; 112     PyTracebackObject *exception_tb = NULL;
113     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 113     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n n 114     static struct Nuitka_FrameObject *cache_frame_0d2430558a94e0abc9ad763ec38305d0 = NULL;
114     PyObject *tmp_return_value = NULL; 115     PyObject *tmp_return_value = NULL;
n 115     static struct Nuitka_FrameObject *cache_frame_0d2430558a94e0abc9ad763ec38305d0 = NULL; n
116 116
117     // Actual function body. 117     // Actual function body.
118     if (isFrameUnusable(cache_frame_0d2430558a94e0abc9ad763ec38305d0)) { 118     if (isFrameUnusable(cache_frame_0d2430558a94e0abc9ad763ec38305d0)) {
119         Py_XDECREF(cache_frame_0d2430558a94e0abc9ad763ec38305d0); 119         Py_XDECREF(cache_frame_0d2430558a94e0abc9ad763ec38305d0);
120 120
159             exception_lineno = 31; 159             exception_lineno = 31;
160             type_description_1 = "oo"; 160             type_description_1 = "oo";
161             goto frame_exception_exit_1; 161             goto frame_exception_exit_1;
162         } 162         }
163     } 163     }
n 164     { n
165         nuitka_bool tmp_condition_result_1;
166         PyObject *tmp_cmp_expr_left_1;
167         PyObject *tmp_cmp_expr_right_1;
168         CHECK_OBJECT(par_value1);
169         tmp_cmp_expr_left_1 = par_value1;
170         CHECK_OBJECT(par_value2);
171         tmp_cmp_expr_right_1 = par_value2;
172         tmp_condition_result_1 = RICH_COMPARE_EQ_NBOOL_OBJECT_OBJECT(tmp_cmp_expr_left_1, tmp_cmp_expr_right_1);
173         if (tmp_condition_result_1 == NUITKA_BOOL_EXCEPTION) {
174             assert(HAS_ERROR_OCCURRED(tstate));
175  
176             FETCH_ERROR_OCCURRED(tstate, &exception_type, &exception_value, &exception_tb);
177  
178  
179             exception_lineno = 34;
180             type_description_1 = "oo";
181             goto frame_exception_exit_1;
182         }
183         if (tmp_condition_result_1 == NUITKA_BOOL_TRUE) {
184             goto branch_yes_1;
185         } else {
186             goto branch_no_1;
187         }
188     }
189     branch_yes_1:;
190     tmp_return_value = Py_None;
191     Py_INCREF(tmp_return_value);
192     goto frame_return_exit_1;
193     branch_no_1:;
194 164
195 165
196     // Put the previous frame back on top. 166     // Put the previous frame back on top.
197     popFrameStack(tstate); 167     popFrameStack(tstate);
198 168
199     goto frame_no_exception_1; 169     goto frame_no_exception_1;
t 200     frame_return_exit_1: t
201  
202     // Put the previous frame back on top.
203     popFrameStack(tstate);
204  
205     goto function_return_exit;
206     frame_exception_exit_1: 170     frame_exception_exit_1:
207 171
208 172
209     if (exception_tb == NULL) { 173     if (exception_tb == NULL) {
210         exception_tb = MAKE_TRACEBACK(frame_0d2430558a94e0abc9ad763ec38305d0, exception_lineno); 174         exception_tb = MAKE_TRACEBACK(frame_0d2430558a94e0abc9ad763ec38305d0, exception_lineno);