Construct FunctionCreationLocal

Performance Diagrams

Construct FunctionCreationLocal 00200000020000004000000400000060000006000000800000080000001000000010000000120000001200000014000000140000001600000016000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)1651931873.61538461538461257.0CPython 2.711200275196.30769230769232336.56850014817616Nuitka (historic)8150372319.0000000000001382.1925357702651Nuitka (master)8150953441.69230769230774382.1838444890354Nuitka (develop)8150354564.3846153846155382.19280503543234Nuitka (factory)Construct FunctionCreationLocalTicks Construct FunctionCreationLocal 002000000200000040000004000000600000060000008000000800000010000000100000001200000012000000140000001400000016000000160000001800000018000000200000002000000022000000220000002400000024000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)2542751173.61538461538461257.0CPython 3.50196.30769230769232504.11538461538464Nuitka (historic)11393654319.0000000000001393.3870010789616Nuitka (master)11401248441.69230769230774393.31319935173906Nuitka (develop)11398595564.3846153846155393.33898233597944Nuitka (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


for x in xrange(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


for x in xrange(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 for x in xrange(50000): 35 for x in xrange(50000):

Context Diff of Generated Code


Construct
Baseline
39 extern PyObject *const_str_plain___file__; 39 extern PyObject *const_str_plain___file__;
40 extern PyObject *const_int_0; 40 extern PyObject *const_int_0;
41 static PyObject *const_xrange_0_50000; 41 static PyObject *const_xrange_0_50000;
42 static PyObject *const_str_plain_empty; 42 static PyObject *const_str_plain_empty;
43 extern PyObject *const_str_plain_print; 43 extern PyObject *const_str_plain_print;
n 44 static PyObject *const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd; n
45 static PyObject *const_int_pos_50000; 44 static PyObject *const_int_pos_50000;
46 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple; 45 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
47 static PyObject *const_str_plain_calledRepeatedly; 46 static PyObject *const_str_plain_calledRepeatedly;
48 static PyObject *const_str_angle_module; 47 static PyObject *const_str_angle_module;
49 static PyObject *const_str_plain_x; 48 static PyObject *const_str_plain_x;
64     const_tuple_str_plain_empty_tuple = PyTuple_New( 1 ); 63     const_tuple_str_plain_empty_tuple = PyTuple_New( 1 );
65     const_str_plain_empty = UNSTREAM_STRING( &constant_bin[ 90 ], 5, 1 ); 64     const_str_plain_empty = UNSTREAM_STRING( &constant_bin[ 90 ], 5, 1 );
66     PyTuple_SET_ITEM( const_tuple_str_plain_empty_tuple, 0, const_str_plain_empty ); Py_INCREF( const_str_plain_empty ); 65     PyTuple_SET_ITEM( const_tuple_str_plain_empty_tuple, 0, const_str_plain_empty ); Py_INCREF( const_str_plain_empty );
67     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul ); 66     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
68     const_xrange_0_50000 = BUILTIN_XRANGE3( const_int_0, const_int_pos_50000, const_int_pos_1 ); 67     const_xrange_0_50000 = BUILTIN_XRANGE3( const_int_0, const_int_pos_50000, const_int_pos_1 );
n 69     const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd = UNSTREAM_STRING( &constant_bin[ 95 ], 31, 0 ); n
70     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 68     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
n 71     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 126 ], 3, 0 ); n 69     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 95 ], 3, 0 );
72     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 ); 70     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 );
n 73     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 95 ], 16, 1 ); n 71     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 98 ], 16, 1 );
74     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 129 ], 8, 0 ); 72     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 114 ], 8, 0 );
75     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 25 ], 1, 1 ); 73     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 25 ], 1, 1 );
76 74
77     constants_created = true; 75     constants_created = true;
78 } 76 }
79 77
88 #endif 86 #endif
89 87
90 // The module code objects. 88 // The module code objects.
91 static PyCodeObject *codeobj_74793b317b684bf24924ceda04e127eb; 89 static PyCodeObject *codeobj_74793b317b684bf24924ceda04e127eb;
92 static PyCodeObject *codeobj_e6662318d2a4706462918ef1a1324d57; 90 static PyCodeObject *codeobj_e6662318d2a4706462918ef1a1324d57;
n 93 static PyCodeObject *codeobj_c9d5e2760f4e73689c2f3568a6146b1b; n
94 /* For use in "MainProgram.c". */ 91 /* For use in "MainProgram.c". */
95 PyCodeObject *codeobj_main = NULL; 92 PyCodeObject *codeobj_main = NULL;
96 93
97 static void createModuleCodeObjects(void) 94 static void createModuleCodeObjects(void)
98 { 95 {
99     module_filename_obj = const_str_digest_3b3dfaf030066341c867c418378babe5; 96     module_filename_obj = const_str_digest_3b3dfaf030066341c867c418378babe5;
100     codeobj_74793b317b684bf24924ceda04e127eb = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE ); 97     codeobj_74793b317b684bf24924ceda04e127eb = MAKE_CODEOBJ( module_filename_obj, const_str_angle_module, 1, const_tuple_empty, 0, 0, CO_NOFREE );
101     codeobj_main = codeobj_74793b317b684bf24924ceda04e127eb; 98     codeobj_main = codeobj_74793b317b684bf24924ceda04e127eb;
102     codeobj_e6662318d2a4706462918ef1a1324d57 = MAKE_CODEOBJ( module_filename_obj, const_str_plain_calledRepeatedly, 23, const_tuple_str_plain_empty_tuple, 0, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE ); 99     codeobj_e6662318d2a4706462918ef1a1324d57 = MAKE_CODEOBJ( module_filename_obj, const_str_plain_calledRepeatedly, 23, const_tuple_str_plain_empty_tuple, 0, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE );
n 103     codeobj_c9d5e2760f4e73689c2f3568a6146b1b = MAKE_CODEOBJ( module_filename_obj, const_str_plain_empty, 26, const_tuple_empty, 0, 0, CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE ); n
104 } 100 }
105 101
106 // The module function declarations. 102 // The module function declarations.
107 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  ); 103 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly(  );
n 108   n
109  
110 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  );
111 104
112 105
113 // The module function definitions. 106 // The module function definitions.
114 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars ) 107 static PyObject *impl___main__$$$function_1_calledRepeatedly( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
115 { 108 {
117 #ifndef __NUITKA_NO_ASSERT__ 110 #ifndef __NUITKA_NO_ASSERT__
118     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 111     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
119 #endif 112 #endif
120 113
121     // Local variable declarations. 114     // Local variable declarations.
n 122     PyObject *var_empty = NULL; n
123     PyObject *tmp_assign_source_1;
124     PyObject *tmp_return_value; 115     PyObject *tmp_return_value;
125     tmp_return_value = NULL; 116     tmp_return_value = NULL;
126 117
127     // Actual function code. 118     // Actual function code.
n 128     tmp_assign_source_1 = MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  ); n 119     tmp_return_value = const_int_pos_1;
129     assert( var_empty == NULL );
130     var_empty = tmp_assign_source_1;
131  
132     // Tried code:
133     tmp_return_value = var_empty;
134  
135     Py_INCREF( tmp_return_value ); 120     Py_INCREF( tmp_return_value );
n 136     goto try_return_handler_1; n
137     // tried codes exits in all cases
138     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
139     return NULL;
140     // Return handler code:
141     try_return_handler_1:;
142     CHECK_OBJECT( (PyObject *)var_empty );
143     Py_DECREF( var_empty );
144     var_empty = NULL;
145  
146     goto function_return_exit; 121     goto function_return_exit;
n 147     // End of try: n
148 122
149     // Return statement must have exited already. 123     // Return statement must have exited already.
150     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 124     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
n 151     return NULL; n
152  
153     function_return_exit:
154  
155     CHECK_OBJECT( tmp_return_value );
156     assert( had_error || !ERROR_OCCURRED() );
157     return tmp_return_value;
158  
159 }
160  
161  
162 static PyObject *impl___main__$$$function_1_calledRepeatedly$$$function_1_empty( struct Nuitka_FunctionObject const *self, PyObject **python_pars )
163 {
164     // Preserve error status for checks
165 #ifndef __NUITKA_NO_ASSERT__
166     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
167 #endif
168  
169     // Local variable declarations.
170     PyObject *tmp_return_value;
171     tmp_return_value = NULL;
172  
173     // Actual function code.
174     tmp_return_value = Py_None;
175     Py_INCREF( tmp_return_value );
176     goto function_return_exit;
177  
178     // Return statement must have exited already.
179     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly$$$function_1_empty );
180     return NULL; 125     return NULL;
181 126
182     function_return_exit: 127     function_return_exit:
183 128
184     CHECK_OBJECT( tmp_return_value ); 129     CHECK_OBJECT( tmp_return_value );
196         const_str_plain_calledRepeatedly, 141         const_str_plain_calledRepeatedly,
197 #if PYTHON_VERSION >= 330 142 #if PYTHON_VERSION >= 330
198         NULL, 143         NULL,
199 #endif 144 #endif
200         codeobj_e6662318d2a4706462918ef1a1324d57, 145         codeobj_e6662318d2a4706462918ef1a1324d57,
t 201         NULL, t
202 #if PYTHON_VERSION >= 300
203         NULL,
204         const_dict_empty,
205 #endif
206         module___main__,
207         Py_None,
208         0
209     );
210  
211  
212     return (PyObject *)result;
213 }
214  
215  
216  
217 static PyObject *MAKE_FUNCTION___main__$$$function_1_calledRepeatedly$$$function_1_empty(  )
218 {
219     struct Nuitka_FunctionObject *result = Nuitka_Function_New(
220         impl___main__$$$function_1_calledRepeatedly$$$function_1_empty,
221         const_str_plain_empty,
222 #if PYTHON_VERSION >= 330
223         const_str_digest_30e4724e0d508bc0c811d26a46d4b6cd,
224 #endif
225         codeobj_c9d5e2760f4e73689c2f3568a6146b1b,
226         NULL, 146         NULL,
227 #if PYTHON_VERSION >= 300 147 #if PYTHON_VERSION >= 300
228         NULL, 148         NULL,
229         const_dict_empty, 149         const_dict_empty,
230 #endif 150 #endif