Construct CallUncompiledFunctionPosArgs

Performance Diagrams

Construct CallUncompiledFunctionPosArgs 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)16133928072.9230769230769257.0CPython 2.7108688497194.46153846153845337.6425967151097Nuitka (historic)107936965316.0338.7936810588031Nuitka (master)107937523437.53846153846143338.79282639783884Nuitka (develop)107437507559.0769230769231339.558676141025Nuitka (factory)Construct CallUncompiledFunctionPosArgsTicks Construct CallUncompiledFunctionPosArgs 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000140000000140000000150000000150000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)15128386972.9230769230769257.0CPython 3.50194.46153846153845504.11538461538464Nuitka (historic)101009001316.0339.1217319759828Nuitka (master)101016390437.53846153846143339.1096623773601Nuitka (develop)100414632559.0769230769231340.0926069609322Nuitka (factory)Construct CallUncompiledFunctionPosArgsTicks

Source Code with Construct

from __future__ import print_function

exec("""
def python_func(a,b,c,d,e,f):
    pass
""")

def calledRepeatedly():
    # This is supposed to make a call to a non-compiled function, which is
    # being optimized separately.
# construct_begin
    python_func("some", "random", "values", "to", "check", "call")
    python_func("some", "other", "values", "to", "check", "call")
    python_func("some", "new", "values", "to", "check", "call")
# construct_alternative



for x in xrange(50000):
    calledRepeatedly()

print("OK.")

Source Code without Construct

from __future__ import print_function

exec("""
def python_func(a,b,c,d,e,f):
    pass
""")

def calledRepeatedly():
    # This is supposed to make a call to a non-compiled function, which is
    # being optimized separately.
# construct_begin



# construct_alternative
    pass
# construct_end

for x in xrange(50000):
    calledRepeatedly()

print("OK.")

Context Diff of Source Code


Construct
Baseline
26 26
27 def calledRepeatedly(): 27 def calledRepeatedly():
28     # This is supposed to make a call to a non-compiled function, which is 28     # This is supposed to make a call to a non-compiled function, which is
29     # being optimized separately. 29     # being optimized separately.
30 # construct_begin 30 # construct_begin
n 31     python_func("some", "random", "values", "to", "check", "call") n
32     python_func("some", "other", "values", "to", "check", "call")
33     python_func("some", "new", "values", "to", "check", "call")
34 # construct_alternative
35 31
36 32
t t 33  
34 # construct_alternative
35     pass
36 # construct_end
37 37
38 for x in xrange(50000): 38 for x in xrange(50000):
39     calledRepeatedly() 39     calledRepeatedly()
40 40
41 print("OK.") 41 print("OK.")

Context Diff of Generated Code


Construct
Baseline
29 29
30 PyObject *module___main__; 30 PyObject *module___main__;
31 PyDictObject *moduledict___main__; 31 PyDictObject *moduledict___main__;
32 32
33 /* The module constants used, if any. */ 33 /* The module constants used, if any. */
n 34 static PyObject *const_str_plain_to; n
35 static PyObject *const_str_plain___package__; 34 static PyObject *const_str_plain___package__;
36 static PyObject *const_str_digest_40641b58ed6f61cc974b85218932eb8d; 35 static PyObject *const_str_digest_40641b58ed6f61cc974b85218932eb8d;
n 37 static PyObject *const_tuple_4cee4124c8df2995a8a82b981e580f5e_tuple; n
38 extern PyObject *const_int_pos_1; 36 extern PyObject *const_int_pos_1;
n 39 static PyObject *const_str_plain_values; n
40 extern PyObject *const_dict_empty; 37 extern PyObject *const_dict_empty;
41 extern PyObject *const_str_plain___file__; 38 extern PyObject *const_str_plain___file__;
n 42 static PyObject *const_str_plain_other; n
43 extern PyObject *const_int_0; 39 extern PyObject *const_int_0;
n 44 static PyObject *const_str_plain_check; n
45 static PyObject *const_xrange_0_50000; 40 static PyObject *const_xrange_0_50000;
46 extern PyObject *const_str_plain_print; 41 extern PyObject *const_str_plain_print;
n 47 static PyObject *const_str_plain_call; n
48 static PyObject *const_int_pos_50000; 42 static PyObject *const_int_pos_50000;
49 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple; 43 static PyObject *const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple;
n 50 static PyObject *const_str_plain_random; n
51 static PyObject *const_str_plain_calledRepeatedly; 44 static PyObject *const_str_plain_calledRepeatedly;
52 static PyObject *const_str_angle_module; 45 static PyObject *const_str_angle_module;
53 static PyObject *const_str_plain_x; 46 static PyObject *const_str_plain_x;
54 extern PyObject *const_tuple_empty; 47 extern PyObject *const_tuple_empty;
55 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352; 48 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352;
n 56 static PyObject *const_str_plain_python_func; n
57 static PyObject *const_str_plain_some;
58 static PyObject *const_str_plain_new;
59 extern PyObject *const_str_plain___loader__; 49 extern PyObject *const_str_plain___loader__;
60 extern PyObject *const_str_plain___main__; 50 extern PyObject *const_str_plain___main__;
n 61 static PyObject *const_tuple_78e2f1ad354bdb7db1a0fda186168ee0_tuple; n
62 static PyObject *const_str_angle_string; 51 static PyObject *const_str_angle_string;
n 63 static PyObject *const_tuple_ca2f155a28955fc472d4376e2721d689_tuple; n
64 static PyObject *const_str_digest_c1cbcfda19e47296bfe4f6d9d6fb4215; 52 static PyObject *const_str_digest_c1cbcfda19e47296bfe4f6d9d6fb4215;
65 extern PyObject *const_str_plain___doc__; 53 extern PyObject *const_str_plain___doc__;
66 extern PyObject *const_str_plain___cached__; 54 extern PyObject *const_str_plain___cached__;
67 static PyObject *const_str_plain_exec; 55 static PyObject *const_str_plain_exec;
68 static PyObject *module_filename_obj; 56 static PyObject *module_filename_obj;
69 57
70 static bool constants_created = false; 58 static bool constants_created = false;
71 59
72 static void createModuleConstants( void ) 60 static void createModuleConstants( void )
73 { 61 {
n 74     const_str_plain_to = UNSTREAM_STRING( &constant_bin[ 0 ], 2, 1 ); n
75     const_str_plain___package__ = UNSTREAM_STRING( &constant_bin[ 2 ], 11, 1 ); 62     const_str_plain___package__ = UNSTREAM_STRING( &constant_bin[ 0 ], 11, 1 );
76     const_str_digest_40641b58ed6f61cc974b85218932eb8d = UNSTREAM_STRING( &constant_bin[ 13 ], 40, 0 ); 63     const_str_digest_40641b58ed6f61cc974b85218932eb8d = UNSTREAM_STRING( &constant_bin[ 11 ], 40, 0 );
77     const_tuple_4cee4124c8df2995a8a82b981e580f5e_tuple = PyTuple_New( 6 );
78     const_str_plain_some = UNSTREAM_STRING( &constant_bin[ 53 ], 4, 1 );
79     PyTuple_SET_ITEM( const_tuple_4cee4124c8df2995a8a82b981e580f5e_tuple, 0, const_str_plain_some ); Py_INCREF( const_str_plain_some );
80     const_str_plain_new = UNSTREAM_STRING( &constant_bin[ 57 ], 3, 1 );
81     PyTuple_SET_ITEM( const_tuple_4cee4124c8df2995a8a82b981e580f5e_tuple, 1, const_str_plain_new ); Py_INCREF( const_str_plain_new );
82     const_str_plain_values = UNSTREAM_STRING( &constant_bin[ 60 ], 6, 1 );
83     PyTuple_SET_ITEM( const_tuple_4cee4124c8df2995a8a82b981e580f5e_tuple, 2, const_str_plain_values ); Py_INCREF( const_str_plain_values );
84     PyTuple_SET_ITEM( const_tuple_4cee4124c8df2995a8a82b981e580f5e_tuple, 3, const_str_plain_to ); Py_INCREF( const_str_plain_to );
85     const_str_plain_check = UNSTREAM_STRING( &constant_bin[ 66 ], 5, 1 );
86     PyTuple_SET_ITEM( const_tuple_4cee4124c8df2995a8a82b981e580f5e_tuple, 4, const_str_plain_check ); Py_INCREF( const_str_plain_check );
87     const_str_plain_call = UNSTREAM_STRING( &constant_bin[ 71 ], 4, 1 );
88     PyTuple_SET_ITEM( const_tuple_4cee4124c8df2995a8a82b981e580f5e_tuple, 5, const_str_plain_call ); Py_INCREF( const_str_plain_call );
89     const_str_plain_other = UNSTREAM_STRING( &constant_bin[ 75 ], 5, 1 );
90     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul ); 64     const_int_pos_50000 = PyLong_FromUnsignedLong( 50000ul );
91     const_xrange_0_50000 = BUILTIN_XRANGE3( const_int_0, const_int_pos_50000, const_int_pos_1 ); 65     const_xrange_0_50000 = BUILTIN_XRANGE3( const_int_0, const_int_pos_50000, const_int_pos_1 );
92     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 ); 66     const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple = PyTuple_New( 1 );
n 93     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 80 ], 3, 0 ); n 67     const_str_digest_5ed1392909ad16e6227b8230f4582352 = UNSTREAM_STRING( &constant_bin[ 51 ], 3, 0 );
94     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 ); 68     PyTuple_SET_ITEM( const_tuple_str_digest_5ed1392909ad16e6227b8230f4582352_tuple, 0, const_str_digest_5ed1392909ad16e6227b8230f4582352 ); Py_INCREF( const_str_digest_5ed1392909ad16e6227b8230f4582352 );
n 95     const_str_plain_random = UNSTREAM_STRING( &constant_bin[ 83 ], 6, 1 ); n
96     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 89 ], 16, 1 ); 69     const_str_plain_calledRepeatedly = UNSTREAM_STRING( &constant_bin[ 54 ], 16, 1 );
97     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 105 ], 8, 0 ); 70     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 70 ], 8, 0 );
98     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 113 ], 1, 1 ); 71     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 78 ], 1, 1 );
99     const_str_plain_python_func = UNSTREAM_STRING( &constant_bin[ 18 ], 11, 1 );
100     const_tuple_78e2f1ad354bdb7db1a0fda186168ee0_tuple = PyTuple_New( 6 );
101     PyTuple_SET_ITEM( const_tuple_78e2f1ad354bdb7db1a0fda186168ee0_tuple, 0, const_str_plain_some ); Py_INCREF( const_str_plain_some );
102     PyTuple_SET_ITEM( const_tuple_78e2f1ad354bdb7db1a0fda186168ee0_tuple, 1, const_str_plain_random ); Py_INCREF( const_str_plain_random );
103     PyTuple_SET_ITEM( const_tuple_78e2f1ad354bdb7db1a0fda186168ee0_tuple, 2, const_str_plain_values ); Py_INCREF( const_str_plain_values );
104     PyTuple_SET_ITEM( const_tuple_78e2f1ad354bdb7db1a0fda186168ee0_tuple, 3, const_str_plain_to ); Py_INCREF( const_str_plain_to );
105     PyTuple_SET_ITEM( const_tuple_78e2f1ad354bdb7db1a0fda186168ee0_tuple, 4, const_str_plain_check ); Py_INCREF( const_str_plain_check );
106     PyTuple_SET_ITEM( const_tuple_78e2f1ad354bdb7db1a0fda186168ee0_tuple, 5, const_str_plain_call ); Py_INCREF( const_str_plain_call );
107     const_str_angle_string = UNSTREAM_STRING( &constant_bin[ 114 ], 8, 0 ); 72     const_str_angle_string = UNSTREAM_STRING( &constant_bin[ 79 ], 8, 0 );
108     const_tuple_ca2f155a28955fc472d4376e2721d689_tuple = PyTuple_New( 6 );
109     PyTuple_SET_ITEM( const_tuple_ca2f155a28955fc472d4376e2721d689_tuple, 0, const_str_plain_some ); Py_INCREF( const_str_plain_some );
110     PyTuple_SET_ITEM( const_tuple_ca2f155a28955fc472d4376e2721d689_tuple, 1, const_str_plain_other ); Py_INCREF( const_str_plain_other );
111     PyTuple_SET_ITEM( const_tuple_ca2f155a28955fc472d4376e2721d689_tuple, 2, const_str_plain_values ); Py_INCREF( const_str_plain_values );
112     PyTuple_SET_ITEM( const_tuple_ca2f155a28955fc472d4376e2721d689_tuple, 3, const_str_plain_to ); Py_INCREF( const_str_plain_to );
113     PyTuple_SET_ITEM( const_tuple_ca2f155a28955fc472d4376e2721d689_tuple, 4, const_str_plain_check ); Py_INCREF( const_str_plain_check );
114     PyTuple_SET_ITEM( const_tuple_ca2f155a28955fc472d4376e2721d689_tuple, 5, const_str_plain_call ); Py_INCREF( const_str_plain_call );
115     const_str_digest_c1cbcfda19e47296bfe4f6d9d6fb4215 = UNSTREAM_STRING( &constant_bin[ 122 ], 87, 0 ); 73     const_str_digest_c1cbcfda19e47296bfe4f6d9d6fb4215 = UNSTREAM_STRING( &constant_bin[ 87 ], 87, 0 );
116     const_str_plain_exec = UNSTREAM_STRING( &constant_bin[ 209 ], 4, 1 ); 74     const_str_plain_exec = UNSTREAM_STRING( &constant_bin[ 174 ], 4, 1 );
117 75
118     constants_created = true; 76     constants_created = true;
119 } 77 }
120 78
121 #ifndef __NUITKA_NO_ASSERT__ 79 #ifndef __NUITKA_NO_ASSERT__
153 #ifndef __NUITKA_NO_ASSERT__ 111 #ifndef __NUITKA_NO_ASSERT__
154     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED(); 112     NUITKA_MAY_BE_UNUSED bool had_error = ERROR_OCCURRED();
155 #endif 113 #endif
156 114
157     // Local variable declarations. 115     // Local variable declarations.
n 158     PyObject *exception_type = NULL, *exception_value = NULL; n
159     PyTracebackObject *exception_tb = NULL;
160     NUITKA_MAY_BE_UNUSED int exception_lineno = -1;
161     PyObject *tmp_called_name_1;
162     PyObject *tmp_called_name_2;
163     PyObject *tmp_called_name_3;
164     PyObject *tmp_return_value; 116     PyObject *tmp_return_value;
n 165     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
166     static struct Nuitka_FrameObject *cache_frame_function = NULL;
167  
168     struct Nuitka_FrameObject *frame_function;
169  
170     tmp_return_value = NULL; 117     tmp_return_value = NULL;
171 118
172     // Actual function code. 119     // Actual function code.
n 173     MAKE_OR_REUSE_FRAME( cache_frame_function, codeobj_8d3318eeaa0a30dc5808b19e60691073, module___main__, 0 ); n
174     frame_function = cache_frame_function;
175  
176     // Push the new frame as the currently active one.
177     pushFrameStack( frame_function );
178  
179     // Mark the frame object as in use, ref count 1 will be up for reuse.
180     assert( Py_REFCNT( frame_function ) == 2 ); // Frame stack
181  
182     // Framed code:
183     tmp_called_name_1 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_python_func );
184  
185     if (unlikely( tmp_called_name_1 == NULL ))
186     {
187         tmp_called_name_1 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_python_func );
188     }
189  
190     if ( tmp_called_name_1 == NULL )
191     {
192  
193         exception_type = PyExc_NameError;
194         Py_INCREF( exception_type );
195         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "python_func" );
196         exception_tb = NULL;
197         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
198         CHAIN_EXCEPTION( exception_value );
199  
200         exception_lineno = 31;
201  
202         goto frame_exception_exit_1;
203     }
204  
205     frame_function->m_frame.f_lineno = 31;
206     tmp_unused = CALL_FUNCTION_WITH_ARGS6( tmp_called_name_1, &PyTuple_GET_ITEM( const_tuple_78e2f1ad354bdb7db1a0fda186168ee0_tuple, 0 ) );
207  
208     if ( tmp_unused == NULL )
209     {
210         assert( ERROR_OCCURRED() );
211  
212         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
213  
214  
215         exception_lineno = 31;
216  
217         goto frame_exception_exit_1;
218     }
219     Py_DECREF( tmp_unused );
220     tmp_called_name_2 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_python_func );
221  
222     if (unlikely( tmp_called_name_2 == NULL ))
223     {
224         tmp_called_name_2 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_python_func );
225     }
226  
227     if ( tmp_called_name_2 == NULL )
228     {
229  
230         exception_type = PyExc_NameError;
231         Py_INCREF( exception_type );
232         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "python_func" );
233         exception_tb = NULL;
234         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
235         CHAIN_EXCEPTION( exception_value );
236  
237         exception_lineno = 32;
238  
239         goto frame_exception_exit_1;
240     }
241  
242     frame_function->m_frame.f_lineno = 32;
243     tmp_unused = CALL_FUNCTION_WITH_ARGS6( tmp_called_name_2, &PyTuple_GET_ITEM( const_tuple_ca2f155a28955fc472d4376e2721d689_tuple, 0 ) );
244  
245     if ( tmp_unused == NULL )
246     {
247         assert( ERROR_OCCURRED() );
248  
249         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
250  
251  
252         exception_lineno = 32;
253  
254         goto frame_exception_exit_1;
255     }
256     Py_DECREF( tmp_unused );
257     tmp_called_name_3 = GET_STRING_DICT_VALUE( moduledict___main__, (Nuitka_StringObject *)const_str_plain_python_func );
258  
259     if (unlikely( tmp_called_name_3 == NULL ))
260     {
261         tmp_called_name_3 = GET_STRING_DICT_VALUE( dict_builtin, (Nuitka_StringObject *)const_str_plain_python_func );
262     }
263  
264     if ( tmp_called_name_3 == NULL )
265     {
266  
267         exception_type = PyExc_NameError;
268         Py_INCREF( exception_type );
269         exception_value = PyUnicode_FromFormat( "name '%s' is not defined", "python_func" );
270         exception_tb = NULL;
271         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
272         CHAIN_EXCEPTION( exception_value );
273  
274         exception_lineno = 33;
275  
276         goto frame_exception_exit_1;
277     }
278  
279     frame_function->m_frame.f_lineno = 33;
280     tmp_unused = CALL_FUNCTION_WITH_ARGS6( tmp_called_name_3, &PyTuple_GET_ITEM( const_tuple_4cee4124c8df2995a8a82b981e580f5e_tuple, 0 ) );
281  
282     if ( tmp_unused == NULL )
283     {
284         assert( ERROR_OCCURRED() );
285  
286         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
287  
288  
289         exception_lineno = 33;
290  
291         goto frame_exception_exit_1;
292     }
293     Py_DECREF( tmp_unused );
294  
295 #if 0
296     RESTORE_FRAME_EXCEPTION( frame_function );
297 #endif
298  
299     // Put the previous frame back on top.
300     popFrameStack();
301  
302     goto frame_no_exception_1;
303  
304     frame_exception_exit_1:;
305  
306 #if 0
307     RESTORE_FRAME_EXCEPTION( frame_function );
308 #endif
309  
310     if ( exception_tb == NULL )
311     {
312         exception_tb = MAKE_TRACEBACK( frame_function, exception_lineno );
313     }
314     else if ( exception_tb->tb_frame != &frame_function->m_frame )
315     {
316         exception_tb = ADD_TRACEBACK( exception_tb, frame_function, exception_lineno );
317     }
318  
319     Nuitka_Frame_AttachLocals( (struct Nuitka_FrameObject *)frame_function, ""  );
320  
321     // Release cached frame.
322     if ( frame_function == cache_frame_function )
323     {
324         Py_DECREF( frame_function );
325     }
326     cache_frame_function = NULL;
327  
328     assertFrameObject( frame_function );
329  
330  
331     // Put the previous frame back on top.
332     popFrameStack();
333  
334     // Return the error.
335     goto function_exception_exit;
336  
337     frame_no_exception_1:;
338  
339     tmp_return_value = Py_None; 120     tmp_return_value = Py_None;
340     Py_INCREF( tmp_return_value ); 121     Py_INCREF( tmp_return_value );
341     goto function_return_exit; 122     goto function_return_exit;
342 123
343     // Return statement must have exited already. 124     // Return statement must have exited already.
344     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 125     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
345     return NULL; 126     return NULL;
346 127
t 347 function_exception_exit: t
348     assert( exception_type );
349     RESTORE_ERROR_OCCURRED( exception_type, exception_value, exception_tb );
350  
351     return NULL;
352     function_return_exit: 128     function_return_exit:
353 129
354     CHECK_OBJECT( tmp_return_value ); 130     CHECK_OBJECT( tmp_return_value );
355     assert( had_error || !ERROR_OCCURRED() ); 131     assert( had_error || !ERROR_OCCURRED() );
356     return tmp_return_value; 132     return tmp_return_value;