Construct FunctionCreationLocal

Performance Diagrams

Construct FunctionCreationLocal 00100000010000002000000200000030000003000000400000040000005000000500000060000006000000700000070000008000000800000090000009000000100000001000000011000000110000001200000012000000130000001300000014000000140000001500000015000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)1501816888.95192307692307257.0CPython 2.77700339242.31730769230768377.41070041862736Nuitka (master)8700335395.6826923076923360.95633686683817Nuitka (develop)8700720549.0480769230769360.9500019115309Nuitka (factory)Construct FunctionCreationLocalTicks Construct FunctionCreationLocal 00200000020000004000000400000060000006000000800000080000001000000010000000120000001200000014000000140000001600000016000000180000001800000020000000200000002200000022000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)2212072588.95192307692307257.0CPython 3.59549555242.31730769230768397.4352483752402Nuitka (master)10554686395.6826923076923386.2067134310263Nuitka (develop)10550008549.0480769230769386.2589723768443Nuitka (factory)Construct FunctionCreationLocalTicks

Source Code with Construct

def calledRepeatedly():
    # We measure making a local function that will remain unused.
# construct_begin
    def empty():
        pass
# construct_alternative



    return empty


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

print("OK.")

Source Code without Construct

def calledRepeatedly():
    # We measure making a local function that will remain unused.
# construct_begin


# construct_alternative
    empty = 1
# construct_end

    return empty


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

print("OK.")

Context Diff of Source Code


Construct
Baseline
21 21
22 22
23 def calledRepeatedly(): 23 def calledRepeatedly():
24     # We measure making a local function that will remain unused. 24     # We measure making a local function that will remain unused.
25 # construct_begin 25 # construct_begin
n 26     def empty(): n
27         pass
28 # construct_alternative
29 26
30 27
t t 28 # construct_alternative
29     empty = 1
30 # construct_end
31 31
32     return empty 32     return empty
33 33
34 34
35 import itertools 35 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[17]; n 36 static PyObject *mod_consts[16];
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__", 17); n 45     loadConstantsBlob(&mod_consts[0], "__main__", 16);
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__", 17); n 56     checkConstantsBlob(&mod_consts[0], "__main__", 16);
57 } 57 }
58 #endif 58 #endif
59 59
60 // The module code objects. 60 // The module code objects.
61 static PyCodeObject *codeobj_5071eb5d0d9998ec02b4fe9e98eb1292; 61 static PyCodeObject *codeobj_5071eb5d0d9998ec02b4fe9e98eb1292;
62 static PyCodeObject *codeobj_7ea2fae78ee9b52389c71efe5cc59b2b; 62 static PyCodeObject *codeobj_7ea2fae78ee9b52389c71efe5cc59b2b;
n 63 static PyCodeObject *codeobj_c726666e9f5ab27e6d76f3fec49ba9b9; n
64 /* For use in "MainProgram.c". */ 63 /* For use in "MainProgram.c". */
65 PyCodeObject *codeobj_main = NULL; 64 PyCodeObject *codeobj_main = NULL;
66 65
67 static void createModuleCodeObjects(void) { 66 static void createModuleCodeObjects(void) {
n 68     module_filename_obj = mod_consts[3]; CHECK_OBJECT(module_filename_obj); n 67     module_filename_obj = mod_consts[2]; CHECK_OBJECT(module_filename_obj);
69     codeobj_5071eb5d0d9998ec02b4fe9e98eb1292 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[14], mod_consts[15], 0, 0, 0); 68     codeobj_5071eb5d0d9998ec02b4fe9e98eb1292 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[13], mod_consts[14], 0, 0, 0);
70     codeobj_7ea2fae78ee9b52389c71efe5cc59b2b = MAKE_CODEOBJECT(module_filename_obj, 23, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[6], mod_consts[16], 0, 0, 0); 69     codeobj_7ea2fae78ee9b52389c71efe5cc59b2b = MAKE_CODEOBJECT(module_filename_obj, 23, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[5], mod_consts[15], 0, 0, 0);
71     codeobj_c726666e9f5ab27e6d76f3fec49ba9b9 = MAKE_CODEOBJECT(module_filename_obj, 26, CO_NOFREE, mod_consts[0], mod_consts[15], 0, 0, 0);
72 } 70 }
73 71
74 // The module function declarations. 72 // The module function declarations.
75 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(); 73 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly();
n 76   n
77  
78 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty();
79 74
80 75
81 // The module function definitions. 76 // The module function definitions.
82 static PyObject *impl___main__$$$function_1_calledRepeatedly(struct Nuitka_FunctionObject const *self, PyObject **python_pars) { 77 static PyObject *impl___main__$$$function_1_calledRepeatedly(struct Nuitka_FunctionObject const *self, PyObject **python_pars) {
83     // Preserve error status for checks 78     // Preserve error status for checks
84 #ifndef __NUITKA_NO_ASSERT__ 79 #ifndef __NUITKA_NO_ASSERT__
85     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 80     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
86 #endif 81 #endif
87 82
88     // Local variable declarations. 83     // Local variable declarations.
n 89     PyObject *var_empty = NULL; n
90     PyObject *tmp_return_value = NULL; 84     PyObject *tmp_return_value = NULL;
91 85
92     // Actual function body. 86     // Actual function body.
n 93     { n 87     tmp_return_value = mod_consts[0];
94         PyObject *tmp_assign_source_1;
95  
96  
97         tmp_assign_source_1 = MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty();
98  
99         assert(var_empty == NULL);
100         var_empty = tmp_assign_source_1;
101     }
102     // Tried code:
103     CHECK_OBJECT(var_empty);
104     tmp_return_value = var_empty;
105     Py_INCREF(tmp_return_value); 88     Py_INCREF(tmp_return_value);
n 106     goto try_return_handler_1; n
107     NUITKA_CANNOT_GET_HERE("tried codes exits in all cases");
108     return NULL;
109     // Return handler code:
110     try_return_handler_1:;
111     CHECK_OBJECT(var_empty);
112     Py_DECREF(var_empty);
113     var_empty = NULL;
114  
115     goto function_return_exit; 89     goto function_return_exit;
n 116     // End of try: n
117 90
118     NUITKA_CANNOT_GET_HERE("Return statement must have exited already."); 91     NUITKA_CANNOT_GET_HERE("Return statement must have exited already.");
119     return NULL; 92     return NULL;
120 93
121 94
133 106
134 107
135 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly() { 108 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly() {
136     struct Nuitka_FunctionObject *result = Nuitka_Function_New( 109     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
137         impl___main__$$$function_1_calledRepeatedly, 110         impl___main__$$$function_1_calledRepeatedly,
n 138         mod_consts[6], n 111         mod_consts[5],
139 #if PYTHON_VERSION >= 300 112 #if PYTHON_VERSION >= 300
140         NULL, 113         NULL,
141 #endif 114 #endif
142         codeobj_7ea2fae78ee9b52389c71efe5cc59b2b, 115         codeobj_7ea2fae78ee9b52389c71efe5cc59b2b,
143         NULL, 116         NULL,
153 126
154     return (PyObject *)result; 127     return (PyObject *)result;
155 } 128 }
156 129
157 130
n 158   n
159 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty() {
160     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
161         NULL,
162         mod_consts[0],
163 #if PYTHON_VERSION >= 300
164         mod_consts[1],
165 #endif
166         codeobj_c726666e9f5ab27e6d76f3fec49ba9b9,
167         NULL,
168 #if PYTHON_VERSION >= 300
169         NULL,
170         NULL,
171 #endif
172         module___main__,
173         NULL,
174         NULL,
175         0
176     );
177  
178     return (PyObject *)result;
179 }
180  
181  
182 extern void _initCompiledCellType(); 131 extern void _initCompiledCellType();
183 extern void _initCompiledGeneratorType(); 132 extern void _initCompiledGeneratorType();
184 extern void _initCompiledFunctionType(); 133 extern void _initCompiledFunctionType();
185 extern void _initCompiledMethodType(); 134 extern void _initCompiledMethodType();
186 extern void _initCompiledFrameType(); 135 extern void _initCompiledFrameType();
190 #ifdef _NUITKA_PLUGIN_DILL_ENABLED 139 #ifdef _NUITKA_PLUGIN_DILL_ENABLED
191 // Provide a way to create find a function via its C code and create it back 140 // Provide a way to create find a function via its C code and create it back
192 // in another process, useful for multiprocessing extensions like dill 141 // in another process, useful for multiprocessing extensions like dill
193 142
194 function_impl_code functable___main__[] = { 143 function_impl_code functable___main__[] = {
n 195     NULL, n
196     impl___main__$$$function_1_calledRepeatedly, 144     impl___main__$$$function_1_calledRepeatedly,
197     NULL 145     NULL
198 }; 146 };
199 147
200 static char const *_reduce_compiled_function_argnames[] = { 148 static char const *_reduce_compiled_function_argnames[] = {
559 507
560     // Module code. 508     // Module code.
561     { 509     {
562         PyObject *tmp_assign_source_1; 510         PyObject *tmp_assign_source_1;
563         tmp_assign_source_1 = Py_None; 511         tmp_assign_source_1 = Py_None;
n 564         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_1); n 512         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[1], tmp_assign_source_1);
565     } 513     }
566     { 514     {
567         PyObject *tmp_assign_source_2; 515         PyObject *tmp_assign_source_2;
n 568         tmp_assign_source_2 = mod_consts[3]; n 516         tmp_assign_source_2 = mod_consts[2];
569         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_2); 517         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_2);
570     } 518     }
571     { 519     {
572         PyObject *tmp_assign_source_3; 520         PyObject *tmp_assign_source_3;
573         tmp_assign_source_3 = Py_None; 521         tmp_assign_source_3 = Py_None;
n 574         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_3); n 522         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_3);
575     } 523     }
576     { 524     {
577         PyObject *tmp_assign_source_4; 525         PyObject *tmp_assign_source_4;
578 526
579 527
580         tmp_assign_source_4 = MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(); 528         tmp_assign_source_4 = MAKE_FUNCTION___main__$$$function_1_calledRepeatedly();
581 529
n 582         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_4); n 530         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_4);
583     } 531     }
584     { 532     {
585         PyObject *tmp_assign_source_5; 533         PyObject *tmp_assign_source_5;
586         PyObject *tmp_name_name_1; 534         PyObject *tmp_name_name_1;
587         PyObject *tmp_globals_name_1; 535         PyObject *tmp_globals_name_1;
588         PyObject *tmp_locals_name_1; 536         PyObject *tmp_locals_name_1;
589         PyObject *tmp_fromlist_name_1; 537         PyObject *tmp_fromlist_name_1;
590         PyObject *tmp_level_name_1; 538         PyObject *tmp_level_name_1;
n 591         tmp_name_name_1 = mod_consts[7]; n 539         tmp_name_name_1 = mod_consts[6];
592         tmp_globals_name_1 = (PyObject *)moduledict___main__; 540         tmp_globals_name_1 = (PyObject *)moduledict___main__;
593         tmp_locals_name_1 = Py_None; 541         tmp_locals_name_1 = Py_None;
594         tmp_fromlist_name_1 = Py_None; 542         tmp_fromlist_name_1 = Py_None;
n 595         tmp_level_name_1 = mod_consts[8]; n 543         tmp_level_name_1 = mod_consts[7];
596         tmp_assign_source_5 = IMPORT_MODULE5(tmp_name_name_1, tmp_globals_name_1, tmp_locals_name_1, tmp_fromlist_name_1, tmp_level_name_1); 544         tmp_assign_source_5 = IMPORT_MODULE5(tmp_name_name_1, tmp_globals_name_1, tmp_locals_name_1, tmp_fromlist_name_1, tmp_level_name_1);
597         assert(!(tmp_assign_source_5 == NULL)); 545         assert(!(tmp_assign_source_5 == NULL));
n 598         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_5); n 546         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_5);
599     } 547     }
600     // Frame without reuse. 548     // Frame without reuse.
601     frame_5071eb5d0d9998ec02b4fe9e98eb1292 = MAKE_MODULE_FRAME(codeobj_5071eb5d0d9998ec02b4fe9e98eb1292, module___main__); 549     frame_5071eb5d0d9998ec02b4fe9e98eb1292 = MAKE_MODULE_FRAME(codeobj_5071eb5d0d9998ec02b4fe9e98eb1292, module___main__);
602 550
603     // Push the new frame as the currently active one, and we should be exclusively 551     // Push the new frame as the currently active one, and we should be exclusively
609     { 557     {
610         PyObject *tmp_assign_source_6; 558         PyObject *tmp_assign_source_6;
611         PyObject *tmp_iter_arg_1; 559         PyObject *tmp_iter_arg_1;
612         PyObject *tmp_called_instance_1; 560         PyObject *tmp_called_instance_1;
613         PyObject *tmp_mvar_value_1; 561         PyObject *tmp_mvar_value_1;
n 614         tmp_mvar_value_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[7]); n 562         tmp_mvar_value_1 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[6]);
615 563
616         if (unlikely(tmp_mvar_value_1 == NULL)) { 564         if (unlikely(tmp_mvar_value_1 == NULL)) {
n 617             tmp_mvar_value_1 = GET_STRING_DICT_VALUE(dict_builtin, (Nuitka_StringObject *)mod_consts[7]); n 565             tmp_mvar_value_1 = GET_STRING_DICT_VALUE(dict_builtin, (Nuitka_StringObject *)mod_consts[6]);
618         } 566         }
619 567
620         CHECK_OBJECT(tmp_mvar_value_1); 568         CHECK_OBJECT(tmp_mvar_value_1);
621         tmp_called_instance_1 = tmp_mvar_value_1; 569         tmp_called_instance_1 = tmp_mvar_value_1;
622         frame_5071eb5d0d9998ec02b4fe9e98eb1292->m_frame.f_lineno = 36; 570         frame_5071eb5d0d9998ec02b4fe9e98eb1292->m_frame.f_lineno = 36;
n 623         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2(tmp_called_instance_1, mod_consts[9], &PyTuple_GET_ITEM(mod_consts[10], 0)); n 571         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2(tmp_called_instance_1, mod_consts[8], &PyTuple_GET_ITEM(mod_consts[9], 0));
624 572
625         if (tmp_iter_arg_1 == NULL) { 573         if (tmp_iter_arg_1 == NULL) {
626             assert(ERROR_OCCURRED()); 574             assert(ERROR_OCCURRED());
627 575
628             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb); 576             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
677     } 625     }
678     { 626     {
679         PyObject *tmp_assign_source_8; 627         PyObject *tmp_assign_source_8;
680         CHECK_OBJECT(tmp_for_loop_1__iter_value); 628         CHECK_OBJECT(tmp_for_loop_1__iter_value);
681         tmp_assign_source_8 = tmp_for_loop_1__iter_value; 629         tmp_assign_source_8 = tmp_for_loop_1__iter_value;
n 682         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[11], tmp_assign_source_8); n 630         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[10], tmp_assign_source_8);
683     } 631     }
684     { 632     {
685         PyObject *tmp_called_name_1; 633         PyObject *tmp_called_name_1;
686         PyObject *tmp_mvar_value_2; 634         PyObject *tmp_mvar_value_2;
687         PyObject *tmp_call_result_1; 635         PyObject *tmp_call_result_1;
n 688         tmp_mvar_value_2 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[6]); n 636         tmp_mvar_value_2 = GET_STRING_DICT_VALUE(moduledict___main__, (Nuitka_StringObject *)mod_consts[5]);
689 637
690         if (unlikely(tmp_mvar_value_2 == NULL)) { 638         if (unlikely(tmp_mvar_value_2 == NULL)) {
n 691             tmp_mvar_value_2 = GET_STRING_DICT_VALUE(dict_builtin, (Nuitka_StringObject *)mod_consts[6]); n 639             tmp_mvar_value_2 = GET_STRING_DICT_VALUE(dict_builtin, (Nuitka_StringObject *)mod_consts[5]);
692         } 640         }
693 641
694         if (unlikely(tmp_mvar_value_2 == NULL)) { 642         if (unlikely(tmp_mvar_value_2 == NULL)) {
695 643
n 696             FORMAT_NAME_ERROR(&exception_type, &exception_value, mod_consts[6]); n 644             FORMAT_NAME_ERROR(&exception_type, &exception_value, mod_consts[5]);
697             NORMALIZE_EXCEPTION(&exception_type, &exception_value, &exception_tb); 645             NORMALIZE_EXCEPTION(&exception_type, &exception_value, &exception_tb);
698             CHAIN_EXCEPTION(exception_value); 646             CHAIN_EXCEPTION(exception_value);
699 647
700             exception_lineno = 37; 648             exception_lineno = 37;
701 649
765     tmp_for_loop_1__for_iterator = NULL; 713     tmp_for_loop_1__for_iterator = NULL;
766 714
767     { 715     {
768         PyObject *tmp_called_name_2; 716         PyObject *tmp_called_name_2;
769         PyObject *tmp_call_result_2; 717         PyObject *tmp_call_result_2;
n 770         tmp_called_name_2 = LOOKUP_BUILTIN(mod_consts[12]); n 718         tmp_called_name_2 = LOOKUP_BUILTIN(mod_consts[11]);
771         assert(tmp_called_name_2 != NULL); 719         assert(tmp_called_name_2 != NULL);
772         frame_5071eb5d0d9998ec02b4fe9e98eb1292->m_frame.f_lineno = 39; 720         frame_5071eb5d0d9998ec02b4fe9e98eb1292->m_frame.f_lineno = 39;
t 773         tmp_call_result_2 = CALL_FUNCTION_WITH_SINGLE_ARG(tmp_called_name_2, mod_consts[13]); t 721         tmp_call_result_2 = CALL_FUNCTION_WITH_SINGLE_ARG(tmp_called_name_2, mod_consts[12]);
774         if (tmp_call_result_2 == NULL) { 722         if (tmp_call_result_2 == NULL) {
775             assert(ERROR_OCCURRED()); 723             assert(ERROR_OCCURRED());
776 724
777             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb); 725             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
778 726