Construct FunctionCreationLocal

Performance Diagrams

Construct FunctionCreationLocal 00100000010000002000000200000030000003000000400000040000005000000500000060000006000000700000070000008000000800000090000009000000100000001000000011000000110000001200000012000000130000001300000014000000140000001500000015000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)1501827288.95192307692307257.0CPython 2.78700720242.31730769230768360.9509933171867Nuitka (master)8350716395.6826923076923366.7100695329407Nuitka (develop)8350716549.0480769230769366.7100695329407Nuitka (factory)Construct FunctionCreationLocalTicks Construct FunctionCreationLocal 00200000020000004000000400000060000006000000800000080000001000000010000000120000001200000014000000140000001600000016000000180000001800000020000000200000002200000022000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)2212075188.95192307692307257.0CPython 3.510550008242.31730769230768386.25911090137805Nuitka (master)10199742395.6826923076923390.1720032488256Nuitka (develop)10200000549.0480769230769390.16912107863027Nuitka (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_9c33a479821f2e2072eeb19a420adaf3; 61 static PyCodeObject *codeobj_9c33a479821f2e2072eeb19a420adaf3;
62 static PyCodeObject *codeobj_8ad5377ba2431741f7ae7ea3246b40f2; 62 static PyCodeObject *codeobj_8ad5377ba2431741f7ae7ea3246b40f2;
n 63 static PyCodeObject *codeobj_c1992d5991d5b8d7524ce6f918f630a7; 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[1]; CHECK_OBJECT(module_filename_obj);
69     codeobj_9c33a479821f2e2072eeb19a420adaf3 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[14], mod_consts[15], 0, 0, 0); 68     codeobj_9c33a479821f2e2072eeb19a420adaf3 = MAKE_CODEOBJECT(module_filename_obj, 1, CO_NOFREE, mod_consts[13], mod_consts[14], 0, 0, 0);
70     codeobj_8ad5377ba2431741f7ae7ea3246b40f2 = MAKE_CODEOBJECT(module_filename_obj, 23, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[6], mod_consts[16], 0, 0, 0); 69     codeobj_8ad5377ba2431741f7ae7ea3246b40f2 = MAKE_CODEOBJECT(module_filename_obj, 23, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE, mod_consts[5], mod_consts[15], 0, 0, 0);
71     codeobj_c1992d5991d5b8d7524ce6f918f630a7 = 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();
76 74
77 75
n 78 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(); n
79  
80  
81 // The module function definitions. 76 // The module function definitions.
n 82 static PyObject *impl___main__$$$function_1_calledRepeatedly(struct Nuitka_FunctionObject const *self, PyObject **python_pars) { n
83     // Preserve error status for checks
84 #ifndef __NUITKA_NO_ASSERT__
85     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
86 #endif
87  
88     // Local variable declarations.
89     PyObject *var_empty = NULL;
90     PyObject *tmp_return_value = NULL;
91  
92     // Actual function body.
93     {
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);
106     goto try_return_handler_1;
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     goto function_return_exit;
115     // End of try:
116  
117     NUITKA_CANNOT_GET_HERE("Return statement must have exited already.");
118     return NULL;
119  
120  
121 function_return_exit:
122    // Function cleanup code if any.
123  
124  
125    // Actual function exit with return value, making sure we did not make
126    // the error status worse despite non-NULL return.
127    CHECK_OBJECT(tmp_return_value);
128    assert(had_error || !ERROR_OCCURRED());
129    return tmp_return_value;
130 }
131  
132  
133 77
134 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly() { 78 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly() {
135     struct Nuitka_FunctionObject *result = Nuitka_Function_New( 79     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
n 136         impl___main__$$$function_1_calledRepeatedly, n 80         NULL,
137         mod_consts[6], 81         mod_consts[5],
138 #if PYTHON_VERSION >= 300 82 #if PYTHON_VERSION >= 300
139         NULL, 83         NULL,
140 #endif 84 #endif
141         codeobj_8ad5377ba2431741f7ae7ea3246b40f2, 85         codeobj_8ad5377ba2431741f7ae7ea3246b40f2,
142         NULL, 86         NULL,
147         module___main__, 91         module___main__,
148         NULL, 92         NULL,
149         NULL, 93         NULL,
150         0 94         0
151     ); 95     );
n 152   n 96     result->m_constant_return_value = mod_consts[4];
153  
154     return (PyObject *)result;
155 }
156  
157  
158  
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_c1992d5991d5b8d7524ce6f918f630a7,
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 97
179     return (PyObject *)result; 98     return (PyObject *)result;
180 } 99 }
181 100
182 101
192 // Provide a way to create find a function via its C code and create it back 111 // Provide a way to create find a function via its C code and create it back
193 // in another process, useful for multiprocessing extensions like dill 112 // in another process, useful for multiprocessing extensions like dill
194 113
195 function_impl_code functable___main__[] = { 114 function_impl_code functable___main__[] = {
196     NULL, 115     NULL,
n 197     impl___main__$$$function_1_calledRepeatedly, n
198     NULL 116     NULL
199 }; 117 };
200 118
201 static char const *_reduce_compiled_function_argnames[] = { 119 static char const *_reduce_compiled_function_argnames[] = {
202     "func", 120     "func",
560 478
561     // Module code. 479     // Module code.
562     { 480     {
563         PyObject *tmp_assign_source_1; 481         PyObject *tmp_assign_source_1;
564         tmp_assign_source_1 = Py_None; 482         tmp_assign_source_1 = Py_None;
n 565         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_1); n 483         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[0], tmp_assign_source_1);
566     } 484     }
567     { 485     {
568         PyObject *tmp_assign_source_2; 486         PyObject *tmp_assign_source_2;
n 569         tmp_assign_source_2 = mod_consts[3]; n 487         tmp_assign_source_2 = mod_consts[1];
570         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[4], tmp_assign_source_2); 488         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[2], tmp_assign_source_2);
571     } 489     }
572     { 490     {
573         PyObject *tmp_assign_source_3; 491         PyObject *tmp_assign_source_3;
574         tmp_assign_source_3 = Py_None; 492         tmp_assign_source_3 = Py_None;
n 575         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_3); n 493         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[3], tmp_assign_source_3);
576     } 494     }
577     { 495     {
578         PyObject *tmp_assign_source_4; 496         PyObject *tmp_assign_source_4;
579 497
580 498
581         tmp_assign_source_4 = MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(); 499         tmp_assign_source_4 = MAKE_FUNCTION___main__$$$function_1_calledRepeatedly();
582 500
n 583         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_4); n 501         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[5], tmp_assign_source_4);
584     } 502     }
585     { 503     {
586         PyObject *tmp_assign_source_5; 504         PyObject *tmp_assign_source_5;
587         PyObject *tmp_name_name_1; 505         PyObject *tmp_name_name_1;
588         PyObject *tmp_globals_name_1; 506         PyObject *tmp_globals_name_1;
589         PyObject *tmp_locals_name_1; 507         PyObject *tmp_locals_name_1;
590         PyObject *tmp_fromlist_name_1; 508         PyObject *tmp_fromlist_name_1;
591         PyObject *tmp_level_name_1; 509         PyObject *tmp_level_name_1;
n 592         tmp_name_name_1 = mod_consts[7]; n 510         tmp_name_name_1 = mod_consts[6];
593         tmp_globals_name_1 = (PyObject *)moduledict___main__; 511         tmp_globals_name_1 = (PyObject *)moduledict___main__;
594         tmp_locals_name_1 = Py_None; 512         tmp_locals_name_1 = Py_None;
595         tmp_fromlist_name_1 = Py_None; 513         tmp_fromlist_name_1 = Py_None;
n 596         tmp_level_name_1 = mod_consts[8]; n 514         tmp_level_name_1 = mod_consts[7];
597         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); 515         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);
598         assert(!(tmp_assign_source_5 == NULL)); 516         assert(!(tmp_assign_source_5 == NULL));
n 599         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[7], tmp_assign_source_5); n 517         UPDATE_STRING_DICT1(moduledict___main__, (Nuitka_StringObject *)mod_consts[6], tmp_assign_source_5);
600     } 518     }
601     // Frame without reuse. 519     // Frame without reuse.
602     frame_9c33a479821f2e2072eeb19a420adaf3 = MAKE_MODULE_FRAME(codeobj_9c33a479821f2e2072eeb19a420adaf3, module___main__); 520     frame_9c33a479821f2e2072eeb19a420adaf3 = MAKE_MODULE_FRAME(codeobj_9c33a479821f2e2072eeb19a420adaf3, module___main__);
603 521
604     // Push the new frame as the currently active one, and we should be exclusively 522     // Push the new frame as the currently active one, and we should be exclusively
609     // Framed code: 527     // Framed code:
610     { 528     {
611         PyObject *tmp_assign_source_6; 529         PyObject *tmp_assign_source_6;
612         PyObject *tmp_iter_arg_1; 530         PyObject *tmp_iter_arg_1;
613         PyObject *tmp_called_instance_1; 531         PyObject *tmp_called_instance_1;
n 614         tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE(moduledict___main__, mod_consts[7]); n 532         tmp_called_instance_1 = GET_MODULE_VARIABLE_VALUE(moduledict___main__, mod_consts[6]);
615         assert(!(tmp_called_instance_1 == NULL)); 533         assert(!(tmp_called_instance_1 == NULL));
616         frame_9c33a479821f2e2072eeb19a420adaf3->m_frame.f_lineno = 36; 534         frame_9c33a479821f2e2072eeb19a420adaf3->m_frame.f_lineno = 36;
n 617         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2(tmp_called_instance_1, mod_consts[9], &PyTuple_GET_ITEM(mod_consts[10], 0)); n 535         tmp_iter_arg_1 = CALL_METHOD_WITH_ARGS2(tmp_called_instance_1, mod_consts[8], &PyTuple_GET_ITEM(mod_consts[9], 0));
618 536
619         if (tmp_iter_arg_1 == NULL) { 537         if (tmp_iter_arg_1 == NULL) {
620             assert(ERROR_OCCURRED()); 538             assert(ERROR_OCCURRED());
621 539
622             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb); 540             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
671     } 589     }
672     { 590     {
673         PyObject *tmp_assign_source_8; 591         PyObject *tmp_assign_source_8;
674         CHECK_OBJECT(tmp_for_loop_1__iter_value); 592         CHECK_OBJECT(tmp_for_loop_1__iter_value);
675         tmp_assign_source_8 = tmp_for_loop_1__iter_value; 593         tmp_assign_source_8 = tmp_for_loop_1__iter_value;
n 676         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[11], tmp_assign_source_8); n 594         UPDATE_STRING_DICT0(moduledict___main__, (Nuitka_StringObject *)mod_consts[10], tmp_assign_source_8);
677     } 595     }
678     { 596     {
679         PyObject *tmp_called_name_1; 597         PyObject *tmp_called_name_1;
680         PyObject *tmp_call_result_1; 598         PyObject *tmp_call_result_1;
n 681         tmp_called_name_1 = GET_MODULE_VARIABLE_VALUE(moduledict___main__, mod_consts[6]); n 599         tmp_called_name_1 = GET_MODULE_VARIABLE_VALUE(moduledict___main__, mod_consts[5]);
682         if (tmp_called_name_1 == NULL) { 600         if (tmp_called_name_1 == NULL) {
683             assert(ERROR_OCCURRED()); 601             assert(ERROR_OCCURRED());
684 602
685             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb); 603             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
686 604
747     Py_DECREF(tmp_for_loop_1__for_iterator); 665     Py_DECREF(tmp_for_loop_1__for_iterator);
748     tmp_for_loop_1__for_iterator = NULL; 666     tmp_for_loop_1__for_iterator = NULL;
749     { 667     {
750         PyObject *tmp_called_name_2; 668         PyObject *tmp_called_name_2;
751         PyObject *tmp_call_result_2; 669         PyObject *tmp_call_result_2;
n 752         tmp_called_name_2 = LOOKUP_BUILTIN(mod_consts[12]); n 670         tmp_called_name_2 = LOOKUP_BUILTIN(mod_consts[11]);
753         assert(tmp_called_name_2 != NULL); 671         assert(tmp_called_name_2 != NULL);
754         frame_9c33a479821f2e2072eeb19a420adaf3->m_frame.f_lineno = 39; 672         frame_9c33a479821f2e2072eeb19a420adaf3->m_frame.f_lineno = 39;
t 755         tmp_call_result_2 = CALL_FUNCTION_WITH_SINGLE_ARG(tmp_called_name_2, mod_consts[13]); t 673         tmp_call_result_2 = CALL_FUNCTION_WITH_SINGLE_ARG(tmp_called_name_2, mod_consts[12]);
756         if (tmp_call_result_2 == NULL) { 674         if (tmp_call_result_2 == NULL) {
757             assert(ERROR_OCCURRED()); 675             assert(ERROR_OCCURRED());
758 676
759             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb); 677             FETCH_ERROR_OCCURRED(&exception_type, &exception_value, &exception_tb);
760 678