Construct InplaceOperationStringAdd

Performance Diagrams

Construct InplaceOperationStringAdd 004000000400000080000008000000120000001200000016000000160000002000000020000000240000002400000028000000280000003200000032000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)3356072188.95192307692307257.0CPython 2.724266796242.31730769230768325.4333286809166Nuitka (master)24254394395.6826923076923325.5246474878039Nuitka (develop)24269502549.0480769230769325.413403774334Nuitka (factory)Construct InplaceOperationStringAddTicks Construct InplaceOperationStringAdd 001000000010000000200000002000000030000000300000004000000040000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)3667402188.95192307692307307.6524784517422CPython 3.546116594242.31730769230768257.06856966131136Nuitka (master)46129394395.6826923076923257.00000000000006Nuitka (develop)46126983549.0480769230769257.0129157385486Nuitka (factory)Construct InplaceOperationStringAddTicks

Source Code with Construct

module_value1 = 5

additiv_global = '*' * 1000

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

    # Make sure we have a local variable s anyway
    s = '2'

    additiv = additiv_global

    s += additiv
# construct_begin
    s += additiv
# construct_end

    return s

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

print("OK.")

Source Code without Construct

module_value1 = 5

additiv_global = '*' * 1000

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

    # Make sure we have a local variable s anyway
    s = '2'

    additiv = additiv_global

    s += additiv
# construct_begin



    return s

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

print("OK.")

Context Diff of Source Code


Construct
Baseline
31 31
32     additiv = additiv_global 32     additiv = additiv_global
33 33
34     s += additiv 34     s += additiv
35 # construct_begin 35 # construct_begin
t 36     s += additiv t 36  
37 # construct_end 37  
38 38
39     return s 39     return s
40 40
41 import itertools 41 import itertools
42 for x in itertools.repeat(None, 50000): 42 for x in itertools.repeat(None, 50000):

Context Diff of Generated Code


Construct
Baseline
144     PyObject *exception_keeper_value_1; 144     PyObject *exception_keeper_value_1;
145     PyTracebackObject *exception_keeper_tb_1; 145     PyTracebackObject *exception_keeper_tb_1;
146     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 146     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
147     PyObject *tmp_assign_source_1; 147     PyObject *tmp_assign_source_1;
148     PyObject *tmp_assign_source_2; 148     PyObject *tmp_assign_source_2;
n 149     PyObject *tmp_assign_source_3; n
150     PyObject *tmp_left_name_1; 149     PyObject *tmp_left_name_1;
n 151     PyObject *tmp_left_name_2; n
152     bool tmp_result;
153     PyObject *tmp_return_value; 150     PyObject *tmp_return_value;
154     PyObject *tmp_right_name_1; 151     PyObject *tmp_right_name_1;
n 155     PyObject *tmp_right_name_2; n
156     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; 152     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
157     static struct Nuitka_FrameObject *cache_frame_7d01f93fc9025beaae019a09ba75c4a5 = NULL; 153     static struct Nuitka_FrameObject *cache_frame_7d01f93fc9025beaae019a09ba75c4a5 = NULL;
158 154
159     struct Nuitka_FrameObject *frame_7d01f93fc9025beaae019a09ba75c4a5; 155     struct Nuitka_FrameObject *frame_7d01f93fc9025beaae019a09ba75c4a5;
160 156
237         type_description_1 = "oo"; 233         type_description_1 = "oo";
238         goto frame_exception_exit_1; 234         goto frame_exception_exit_1;
239     } 235     }
240     assert( var_s == NULL ); 236     assert( var_s == NULL );
241     var_s = tmp_assign_source_2; 237     var_s = tmp_assign_source_2;
n 242   n
243     tmp_left_name_2 = var_s;
244  
245     CHECK_OBJECT( tmp_left_name_2 );
246     tmp_right_name_2 = var_additiv;
247  
248     if ( tmp_right_name_2 == NULL )
249     {
250  
251         exception_type = PyExc_UnboundLocalError;
252         Py_INCREF( exception_type );
253         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "additiv" );
254         exception_tb = NULL;
255         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
256         CHAIN_EXCEPTION( exception_value );
257  
258         exception_lineno = 36;
259         type_description_1 = "oo";
260         goto frame_exception_exit_1;
261     }
262  
263     tmp_result = BINARY_OPERATION_ADD_INPLACE( &tmp_left_name_2, tmp_right_name_2 );
264     tmp_assign_source_3 = tmp_left_name_2;
265     if ( tmp_result == false )
266     {
267         assert( ERROR_OCCURRED() );
268  
269         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
270  
271  
272         exception_lineno = 36;
273         type_description_1 = "oo";
274         goto frame_exception_exit_1;
275     }
276     var_s = tmp_assign_source_3;
277 238
278 239
279 #if 0 240 #if 0
280     RESTORE_FRAME_EXCEPTION( frame_7d01f93fc9025beaae019a09ba75c4a5 ); 241     RESTORE_FRAME_EXCEPTION( frame_7d01f93fc9025beaae019a09ba75c4a5 );
281 #endif 242 #endif
352     exception_keeper_lineno_1 = exception_lineno; 313     exception_keeper_lineno_1 = exception_lineno;
353     exception_type = NULL; 314     exception_type = NULL;
354     exception_value = NULL; 315     exception_value = NULL;
355     exception_tb = NULL; 316     exception_tb = NULL;
356     exception_lineno = 0; 317     exception_lineno = 0;
t 357   t
358     Py_XDECREF( var_s );
359     var_s = NULL;
360 318
361     Py_XDECREF( var_additiv ); 319     Py_XDECREF( var_additiv );
362     var_additiv = NULL; 320     var_additiv = NULL;
363 321
364     // Re-raise. 322     // Re-raise.