Construct InplaceOperationFloatAdd

Performance Diagrams

Construct InplaceOperationFloatAdd 0010000001000000200000020000003000000300000040000004000000500000050000006000000600000070000007000000800000080000009000000900000010000000100000001100000011000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)1177851288.95192307692307257.0CPython 2.7850180242.31730769230768486.2784492119731Nuitka (master)800180395.6826923076923487.32745856313466Nuitka (develop)800180549.0480769230769487.32745856313466Nuitka (factory)Construct InplaceOperationFloatAddTicks Construct InplaceOperationFloatAdd 0010000001000000200000020000003000000300000040000004000000500000050000006000000600000070000007000000800000080000009000000900000010000000100000001100000011000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)1117227488.95192307692307257.0CPython 3.5950158242.31730769230768483.0991922435018Nuitka (master)850158395.6826923076923485.3110551517637Nuitka (develop)850158549.0480769230769485.3110551517637Nuitka (factory)Construct InplaceOperationFloatAddTicks

Source Code with Construct

module_value1 = 5.0
module_value2 = 3.0

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

    # Make sure we have a local variable s anyway
    s = 2.0

    local_value = module_value1

    s += module_value1
# construct_begin
    s += 1000.0
# construct_end
    s += module_value2

    return s

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

print("OK.")

Source Code without Construct

module_value1 = 5.0
module_value2 = 3.0

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

    # Make sure we have a local variable s anyway
    s = 2.0

    local_value = module_value1

    s += module_value1
# construct_begin


    s += module_value2

    return s

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

print("OK.")

Context Diff of Source Code


Construct
Baseline
30 30
31     local_value = module_value1 31     local_value = module_value1
32 32
33     s += module_value1 33     s += module_value1
34 # construct_begin 34 # construct_begin
t 35     s += 1000.0 t 35  
36 # construct_end 36  
37     s += module_value2 37     s += module_value2
38 38
39     return s 39     return s
40 40
41 import itertools 41 import itertools

Context Diff of Generated Code


Construct
Baseline
31 31
32 PyObject *module___main__; 32 PyObject *module___main__;
33 PyDictObject *moduledict___main__; 33 PyDictObject *moduledict___main__;
34 34
35 /* The declarations of module constants used, if any. */ 35 /* The declarations of module constants used, if any. */
n 36 static PyObject *mod_consts[21]; n 36 static PyObject *mod_consts[20];
37 37
38 static PyObject *module_filename_obj = NULL; 38 static PyObject *module_filename_obj = NULL;
39 39
40 /* Indicator if this modules private constants were created yet. */ 40 /* Indicator if this modules private constants were created yet. */
41 static bool constants_created = false; 41 static bool constants_created = false;
42 42
43 /* Function to create module private constants. */ 43 /* Function to create module private constants. */
44 static void createModuleConstants(void) { 44 static void createModuleConstants(void) {
n 45     loadConstantsBlob(&mod_consts[0], "__main__", 21); n 45     loadConstantsBlob(&mod_consts[0], "__main__", 20);
46 46
47     constants_created = true; 47     constants_created = true;
48 } 48 }
49 49
50 /* Function to verify module private constants for non-corruption. */ 50 /* Function to verify module private constants for non-corruption. */
51 #ifndef __NUITKA_NO_ASSERT__ 51 #ifndef __NUITKA_NO_ASSERT__
52 void checkModuleConstants___main__(void) { 52 void checkModuleConstants___main__(void) {
53     // The module may not have been used at all, then ignore this. 53     // The module may not have been used at all, then ignore this.
54     if (constants_created == false) return; 54     if (constants_created == false) return;
55 55
n 56     checkConstantsBlob(&mod_consts[0], "__main__", 21); n 56     checkConstantsBlob(&mod_consts[0], "__main__", 20);
57 } 57 }
58 #endif 58 #endif
59 59
60 // The module code objects. 60 // The module code objects.
61 static PyCodeObject *codeobj_300f4474da3df5689e41cb6f8803c330; 61 static PyCodeObject *codeobj_300f4474da3df5689e41cb6f8803c330;
62 static PyCodeObject *codeobj_56b252b6466e1b3be5494bb46c097522; 62 static PyCodeObject *codeobj_56b252b6466e1b3be5494bb46c097522;
63 /* For use in "MainProgram.c". */ 63 /* For use in "MainProgram.c". */
64 PyCodeObject *codeobj_main = NULL; 64 PyCodeObject *codeobj_main = NULL;
65 65
66 static void createModuleCodeObjects(void) { 66 static void createModuleCodeObjects(void) {
n 67     module_filename_obj = mod_consts[5]; CHECK_OBJECT(module_filename_obj); n 67     module_filename_obj = mod_consts[4]; CHECK_OBJECT(module_filename_obj);
68     codeobj_300f4474da3df5689e41cb6f8803c330 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[18], mod_consts[19], 0, 0, 0); 68     codeobj_300f4474da3df5689e41cb6f8803c330 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[17], mod_consts[18], 0, 0, 0);
69     codeobj_56b252b6466e1b3be5494bb46c097522 = MAKE_CODEOBJECT(module_filename_obj, 24, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[10], mod_consts[20], 0, 0, 0); 69     codeobj_56b252b6466e1b3be5494bb46c097522 = MAKE_CODEOBJECT(module_filename_obj, 24, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[9], mod_consts[19], 0, 0, 0);
70 } 70 }
71 71
72 // The module function declarations. 72 // The module function declarations.
73 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(); 73 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly();
74 74
201         PyObject *tmp_assign_source_4; 201         PyObject *tmp_assign_source_4;
202         PyObject *tmp_left_name_2; 202         PyObject *tmp_left_name_2;
203         PyObject *tmp_right_name_2; 203         PyObject *tmp_right_name_2;
204         CHECK_OBJECT(var_s); 204         CHECK_OBJECT(var_s);
205         tmp_left_name_2 = var_s; 205         tmp_left_name_2 = var_s;
n 206         tmp_right_name_2 = mod_consts[2]; n
207         tmp_result = BINARY_OPERATION_ADD_OBJECT_FLOAT_INPLACE(&tmp_left_name_2, tmp_right_name_2);
208         if (tmp_result == false) {
209             assert(ERROR_OCCURRED());
210  
211             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
212  
213  
214             exception_lineno = 35;
215             type_description_1 = "oo";
216             goto frame_exception_exit_1;
217         }
218         tmp_assign_source_4 = tmp_left_name_2;
219         var_s = tmp_assign_source_4;
220  
221     }
222     {
223         PyObject *tmp_assign_source_5;
224         PyObject *tmp_left_name_3;
225         PyObject *tmp_right_name_3;
226         CHECK_OBJECT(var_s);
227         tmp_left_name_3 = var_s;
228         tmp_right_name_3 = GET_MODULE_VARIABLE_VALUE(moduledict___main__, mod_consts[3]); 206         tmp_right_name_2 = GET_MODULE_VARIABLE_VALUE(moduledict___main__, mod_consts[2]);
229         if (tmp_right_name_3 == NULL) { 207         if (tmp_right_name_2 == NULL) {
230             assert(ERROR_OCCURRED()); 208             assert(ERROR_OCCURRED());
231 209
232             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb); 210             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
233 211
234 212
235             exception_lineno = 37; 213             exception_lineno = 37;
236             type_description_1 = "oo"; 214             type_description_1 = "oo";
237             goto frame_exception_exit_1; 215             goto frame_exception_exit_1;
238         } 216         }
n 239         tmp_result = BINARY_OPERATION_ADD_OBJECT_OBJECT_INPLACE(&tmp_left_name_3, tmp_right_name_3); n 217         tmp_result = BINARY_OPERATION_ADD_OBJECT_OBJECT_INPLACE(&tmp_left_name_2, tmp_right_name_2);
240         if (tmp_result == false) { 218         if (tmp_result == false) {
241             assert(ERROR_OCCURRED()); 219             assert(ERROR_OCCURRED());
242 220
243             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb); 221             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
244 222
245 223
246             exception_lineno = 37; 224             exception_lineno = 37;
247             type_description_1 = "oo"; 225             type_description_1 = "oo";
248             goto frame_exception_exit_1; 226             goto frame_exception_exit_1;
249         } 227         }
n 250         tmp_assign_source_5 = tmp_left_name_3; n 228         tmp_assign_source_4 = tmp_left_name_2;
251         var_s = tmp_assign_source_5; 229         var_s = tmp_assign_source_4;
252 230
253     } 231     }
254 232
255 #if 0 233 #if 0
256     RESTORE_FRAME_EXCEPTION(frame_56b252b6466e1b3be5494bb46c097522); 234     RESTORE_FRAME_EXCEPTION(frame_56b252b6466e1b3be5494bb46c097522);
364 342
365 343
366 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly() { 344 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly() {
367     struct Nuitka_FunctionObject *result = Nuitka_Function_New( 345     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
368         impl___main__$$$function_1_calledRepeatedly, 346         impl___main__$$$function_1_calledRepeatedly,
n 369         mod_consts[10], n 347         mod_consts[9],
370 #if PYTHON_VERSION >= 300 348 #if PYTHON_VERSION >= 300
371         NULL, 349         NULL,
372 #endif 350 #endif
373         codeobj_56b252b6466e1b3be5494bb46c097522, 351         codeobj_56b252b6466e1b3be5494bb46c097522,
374         NULL, 352         NULL,
766 744
767     // Module code. 745     // Module code.
768     { 746     {
769         PyObject *tmp_assign_source_1; 747         PyObject *tmp_assign_source_1;
770         tmp_assign_source_1 = Py_None; 748         tmp_assign_source_1 = Py_None;
n 771         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_1); n 749         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_1);
772     } 750     }
773     { 751     {
774         PyObject *tmp_assign_source_2; 752         PyObject *tmp_assign_source_2;
n 775         tmp_assign_source_2 = mod_consts[5]; n 753         tmp_assign_source_2 = mod_consts[4];
776         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_2); 754         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_2);
777     } 755     }
778     { 756     {
779         PyObject *tmp_assign_source_3; 757         PyObject *tmp_assign_source_3;
780         tmp_assign_source_3 = Py_None; 758         tmp_assign_source_3 = Py_None;
n 781         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_3); n 759         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_3);
782     } 760     }
783     { 761     {
784         PyObject *tmp_assign_source_4; 762         PyObject *tmp_assign_source_4;
n 785         tmp_assign_source_4 = mod_consts[8]; n 763         tmp_assign_source_4 = mod_consts[7];
786         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_4); 764         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_4);
787     } 765     }
788     { 766     {
789         PyObject *tmp_assign_source_5; 767         PyObject *tmp_assign_source_5;
n 790         tmp_assign_source_5 = mod_consts[9]; n 768         tmp_assign_source_5 = mod_consts[8];
791         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_5); 769         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_5);
792     } 770     }
793     { 771     {
794         PyObject *tmp_assign_source_6; 772         PyObject *tmp_assign_source_6;
795 773
796 774
797         tmp_assign_source_6 = MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(); 775         tmp_assign_source_6 = MAKE_FUNCTION___main__$$$function_1_calledRepeatedly();
798 776
n 799         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[10], tmp_assign_source_6); n 777         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[9], tmp_assign_source_6);
800     } 778     }
801     { 779     {
802         PyObject *tmp_assign_source_7; 780         PyObject *tmp_assign_source_7;
803         PyObject *tmp_name_name_1; 781         PyObject *tmp_name_name_1;
804         PyObject *tmp_globals_name_1; 782         PyObject *tmp_globals_name_1;
805         PyObject *tmp_locals_name_1; 783         PyObject *tmp_locals_name_1;
806         PyObject *tmp_fromlist_name_1; 784         PyObject *tmp_fromlist_name_1;
807         PyObject *tmp_level_name_1; 785         PyObject *tmp_level_name_1;
n 808         tmp_name_name_1 = mod_consts[11]; n 786         tmp_name_name_1 = mod_consts[10];
809         tmp_globals_name_1 = (PyObject *)moduledict___main__; 787         tmp_globals_name_1 = (PyObject *)moduledict___main__;
810         tmp_locals_name_1 = Py_None; 788         tmp_locals_name_1 = Py_None;
811         tmp_fromlist_name_1 = Py_None; 789         tmp_fromlist_name_1 = Py_None;
n 812         tmp_level_name_1 = mod_consts[12]; n 790         tmp_level_name_1 = mod_consts[11];
813         tmp_assign_source_7 = IMPORT_MODULE5(tmp_name_name_1, tmp_globals_name_1, tmp_locals_name_1, tmp_fromlist_name_1, tmp_level_name_1); 791         tmp_assign_source_7 = IMPORT_MODULE5(tmp_name_name_1, tmp_globals_name_1, tmp_locals_name_1, tmp_fromlist_name_1, tmp_level_name_1);
814         assert(!(tmp_assign_source_7 == NULL)); 792         assert(!(tmp_assign_source_7 == NULL));
n 815         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[11], tmp_assign_source_7); n 793         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[10], tmp_assign_source_7);
816     } 794     }
817     // Frame without reuse. 795     // Frame without reuse.
818     frame_300f4474da3df5689e41cb6f8803c330 = MAKE_MODULE_FRAME(codeobj_300f4474da3df5689e41cb6f8803c330, module___main__); 796     frame_300f4474da3df5689e41cb6f8803c330 = MAKE_MODULE_FRAME(codeobj_300f4474da3df5689e41cb6f8803c330, module___main__);
819 797
820     // Push the new frame as the currently active one, and we should be exclusively 798     // Push the new frame as the currently active one, and we should be exclusively
825     // Framed code: 803     // Framed code:
826     { 804     {
827         PyObject *tmp_assign_source_8; 805         PyObject *tmp_assign_source_8;
828         PyObject *tmp_iter_arg_1; 806         PyObject *tmp_iter_arg_1;
829         PyObject *tmp_called_instance_1; 807         PyObject *tmp_called_instance_1;
n 830         tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE(moduledict___main__, mod_consts[11]); n 808         tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE(moduledict___main__, mod_consts[10]);
831         assert(!(tmp_called_instance_1 == NULL)); 809         assert(!(tmp_called_instance_1 == NULL));
832         frame_300f4474da3df5689e41cb6f8803c330->m_frame.f_lineno = 42; 810         frame_300f4474da3df5689e41cb6f8803c330->m_frame.f_lineno = 42;
n 833         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2(tmp_called_instance_1, mod_consts[13], &PyTuple_GET_ITEM(mod_consts[14], 0)); n 811         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2(tmp_called_instance_1, mod_consts[12], &PyTuple_GET_ITEM(mod_consts[13], 0));
834 812
835         if (tmp_iter_arg_1 == NULL) { 813         if (tmp_iter_arg_1 == NULL) {
836             assert(ERROR_OCCURRED()); 814             assert(ERROR_OCCURRED());
837 815
838             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb); 816             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
887     } 865     }
888     { 866     {
889         PyObject *tmp_assign_source_10; 867         PyObject *tmp_assign_source_10;
890         CHECK_OBJECT(tmp_for_loop_1__iter_value); 868         CHECK_OBJECT(tmp_for_loop_1__iter_value);
891         tmp_assign_source_10 = tmp_for_loop_1__iter_value; 869         tmp_assign_source_10 = tmp_for_loop_1__iter_value;
n 892         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[15], tmp_assign_source_10); n 870         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[14], tmp_assign_source_10);
893     } 871     }
894     { 872     {
895         PyObject *tmp_called_name_1; 873         PyObject *tmp_called_name_1;
896         PyObject *tmp_call_result_1; 874         PyObject *tmp_call_result_1;
n 897         tmp_called_name_1 = GET_MODULE_VARIABLE_VALUE(moduledict___main__, mod_consts[10]); n 875         tmp_called_name_1 = GET_MODULE_VARIABLE_VALUE(moduledict___main__, mod_consts[9]);
898         if (tmp_called_name_1 == NULL) { 876         if (tmp_called_name_1 == NULL) {
899             assert(ERROR_OCCURRED()); 877             assert(ERROR_OCCURRED());
900 878
901             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb); 879             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
902 880
963     Py_DECREF(tmp_for_loop_1__for_iterator); 941     Py_DECREF(tmp_for_loop_1__for_iterator);
964     tmp_for_loop_1__for_iterator = NULL; 942     tmp_for_loop_1__for_iterator = NULL;
965     { 943     {
966         PyObject *tmp_called_name_2; 944         PyObject *tmp_called_name_2;
967         PyObject *tmp_call_result_2; 945         PyObject *tmp_call_result_2;
n 968         tmp_called_name_2 = LOOKUP_BUILTIN(mod_consts[16]); n 946         tmp_called_name_2 = LOOKUP_BUILTIN(mod_consts[15]);
969         assert(tmp_called_name_2 != NULL); 947         assert(tmp_called_name_2 != NULL);
970         frame_300f4474da3df5689e41cb6f8803c330->m_frame.f_lineno = 45; 948         frame_300f4474da3df5689e41cb6f8803c330->m_frame.f_lineno = 45;
t 971         tmp_call_result_2 = CALL_FUNCTION_WITH_SINGLE_ARG(tmp_called_name_2, mod_consts[17]); t 949         tmp_call_result_2 = CALL_FUNCTION_WITH_SINGLE_ARG(tmp_called_name_2, mod_consts[16]);
972         if (tmp_call_result_2 == NULL) { 950         if (tmp_call_result_2 == NULL) {
973             assert(ERROR_OCCURRED()); 951             assert(ERROR_OCCURRED());
974 952
975             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb); 953             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
976 954