Construct CallCompiledObjectMethodPosArgsConstant1

Performance Diagrams

Construct CallCompiledObjectMethodPosArgsConstant1 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000140000000140000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)14774152988.11538461538461257.0CPython 2.738200999240.03846153846155440.21964301535746Nuitka (master)38202187391.96153846153845440.21765594321255Nuitka (develop)38200800543.8846153846154440.21997586666794Nuitka (factory)Construct CallCompiledObjectMethodPosArgsConstant1Ticks Construct CallCompiledObjectMethodPosArgsConstant1 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000140000000140000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)14124554088.11538461538461257.0CPython 3.536205277240.03846153846155440.77263445873166Nuitka (master)36209264391.96153846153845440.76565902404917Nuitka (develop)36208612543.8846153846154440.7667997271876Nuitka (factory)Construct CallCompiledObjectMethodPosArgsConstant1Ticks

Source Code with Construct

from __future__ import print_function

class C(object):
    def compiled_method(self, a):
        return a

def calledRepeatedly():
    inst = C()

    # This is supposed to make a call to a non-compiled function, which is
    # being optimized separately.
# construct_begin
    inst.compiled_method("some")
    inst.compiled_method("some")
    inst.compiled_method("some")

# construct_alternative



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

print("OK.")

Source Code without Construct

from __future__ import print_function

class C(object):
    def compiled_method(self, a):
        return a

def calledRepeatedly():
    inst = C()

    # This is supposed to make a call to a non-compiled function, which is
    # being optimized separately.
# construct_begin




# construct_alternative
    pass
# construct_end

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

print("OK.")

Context Diff of Source Code


Construct
Baseline
27     inst = C() 27     inst = C()
28 28
29     # This is supposed to make a call to a non-compiled function, which is 29     # This is supposed to make a call to a non-compiled function, which is
30     # being optimized separately. 30     # being optimized separately.
31 # construct_begin 31 # construct_begin
n 32     inst.compiled_method("some") n 32  
33     inst.compiled_method("some") 33  
34     inst.compiled_method("some") 34  
35 35
36 # construct_alternative 36 # construct_alternative
t 37   t 37     pass
38   38 # construct_end
39 39
40 import itertools 40 import itertools
41 for x in itertools.repeat(None, 50000): 41 for x in itertools.repeat(None, 50000):
42     calledRepeatedly() 42     calledRepeatedly()
43 43

Context Diff of Generated Code


Construct
Baseline
58 static PyObject *const_str_plain_C; 58 static PyObject *const_str_plain_C;
59 extern PyObject *const_tuple_empty; 59 extern PyObject *const_tuple_empty;
60 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352; 60 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352;
61 static PyObject *const_tuple_str_plain_inst_tuple; 61 static PyObject *const_tuple_str_plain_inst_tuple;
62 static PyObject *const_str_plain_repeat; 62 static PyObject *const_str_plain_repeat;
n 63 static PyObject *const_str_plain_some; n
64 static PyObject *const_tuple_none_int_pos_50000_tuple; 63 static PyObject *const_tuple_none_int_pos_50000_tuple;
65 extern PyObject *const_str_plain___loader__; 64 extern PyObject *const_str_plain___loader__;
66 extern PyObject *const_str_plain___main__; 65 extern PyObject *const_str_plain___main__;
n 67 static PyObject *const_tuple_str_plain_some_tuple; n
68 extern PyObject *const_str_plain___doc__; 66 extern PyObject *const_str_plain___doc__;
69 extern PyObject *const_str_plain___cached__; 67 extern PyObject *const_str_plain___cached__;
70 static PyObject *const_str_plain_print_function; 68 static PyObject *const_str_plain_print_function;
71 static PyObject *module_filename_obj; 69 static PyObject *module_filename_obj;
72 70
100     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 110 ], 1, 1 ); 98     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 110 ], 1, 1 );
101     const_str_plain_C = UNSTREAM_STRING( &constant_bin[ 52 ], 1, 1 ); 99     const_str_plain_C = UNSTREAM_STRING( &constant_bin[ 52 ], 1, 1 );
102     const_tuple_str_plain_inst_tuple = PyTuple_New( 1 ); 100     const_tuple_str_plain_inst_tuple = PyTuple_New( 1 );
103     PyTuple_SET_ITEM( const_tuple_str_plain_inst_tuple, 0, const_str_plain_inst ); Py_INCREF( const_str_plain_inst ); 101     PyTuple_SET_ITEM( const_tuple_str_plain_inst_tuple, 0, const_str_plain_inst ); Py_INCREF( const_str_plain_inst );
104     const_str_plain_repeat = UNSTREAM_STRING( &constant_bin[ 225 ], 6, 1 ); 102     const_str_plain_repeat = UNSTREAM_STRING( &constant_bin[ 225 ], 6, 1 );
n 105     const_str_plain_some = UNSTREAM_STRING( &constant_bin[ 231 ], 4, 1 ); n
106     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 ); 103     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 );
107     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None ); 104     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None );
108     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 ); 105     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 );
n 109     const_tuple_str_plain_some_tuple = PyTuple_New( 1 ); n
110     PyTuple_SET_ITEM( const_tuple_str_plain_some_tuple, 0, const_str_plain_some ); Py_INCREF( const_str_plain_some );
111     const_str_plain_print_function = UNSTREAM_STRING( &constant_bin[ 235 ], 14, 1 ); 106     const_str_plain_print_function = UNSTREAM_STRING( &constant_bin[ 231 ], 14, 1 );
112 107
113     constants_created = true; 108     constants_created = true;
114 } 109 }
115 110
116 #ifndef __NUITKA_NO_ASSERT__ 111 #ifndef __NUITKA_NO_ASSERT__
211     PyObject *exception_keeper_type_1; 206     PyObject *exception_keeper_type_1;
212     PyObject *exception_keeper_value_1; 207     PyObject *exception_keeper_value_1;
213     PyTracebackObject *exception_keeper_tb_1; 208     PyTracebackObject *exception_keeper_tb_1;
214     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 209     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
215     PyObject *tmp_assign_source_1; 210     PyObject *tmp_assign_source_1;
n 216     PyObject *tmp_called_instance_1; n
217     PyObject *tmp_called_instance_2;
218     PyObject *tmp_called_instance_3;
219     PyObject *tmp_called_name_1; 211     PyObject *tmp_called_name_1;
220     PyObject *tmp_return_value; 212     PyObject *tmp_return_value;
n 221     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
222     static struct Nuitka_FrameObject *cache_frame_22e26ed2ccfcf999c93f40ab13693c50 = NULL; 213     static struct Nuitka_FrameObject *cache_frame_22e26ed2ccfcf999c93f40ab13693c50 = NULL;
223 214
224     struct Nuitka_FrameObject *frame_22e26ed2ccfcf999c93f40ab13693c50; 215     struct Nuitka_FrameObject *frame_22e26ed2ccfcf999c93f40ab13693c50;
225 216
226     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 217     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
274         goto frame_exception_exit_1; 265         goto frame_exception_exit_1;
275     } 266     }
276     assert( var_inst == NULL ); 267     assert( var_inst == NULL );
277     var_inst = tmp_assign_source_1; 268     var_inst = tmp_assign_source_1;
278 269
n 279     tmp_called_instance_1 = var_inst; n
280  
281     CHECK_OBJECT( tmp_called_instance_1 );
282     frame_22e26ed2ccfcf999c93f40ab13693c50->m_frame.f_lineno = 32;
283     tmp_unused = CALL_METHOD_WITH_ARGS1( tmp_called_instance_1, const_str_plain_compiled_method, &PyTuple_GET_ITEM( const_tuple_str_plain_some_tuple, 0 ) );
284  
285     if ( tmp_unused == NULL )
286     {
287         assert( ERROR_OCCURRED() );
288  
289         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
290  
291  
292         exception_lineno = 32;
293         type_description_1 = "o";
294         goto frame_exception_exit_1;
295     }
296     Py_DECREF( tmp_unused );
297     tmp_called_instance_2 = var_inst;
298  
299     if ( tmp_called_instance_2 == NULL )
300     {
301  
302         exception_type = PyExc_UnboundLocalError;
303         Py_INCREF( exception_type );
304         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
305         exception_tb = NULL;
306         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
307         CHAIN_EXCEPTION( exception_value );
308  
309         exception_lineno = 33;
310         type_description_1 = "o";
311         goto frame_exception_exit_1;
312     }
313  
314     frame_22e26ed2ccfcf999c93f40ab13693c50->m_frame.f_lineno = 33;
315     tmp_unused = CALL_METHOD_WITH_ARGS1( tmp_called_instance_2, const_str_plain_compiled_method, &PyTuple_GET_ITEM( const_tuple_str_plain_some_tuple, 0 ) );
316  
317     if ( tmp_unused == NULL )
318     {
319         assert( ERROR_OCCURRED() );
320  
321         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
322  
323  
324         exception_lineno = 33;
325         type_description_1 = "o";
326         goto frame_exception_exit_1;
327     }
328     Py_DECREF( tmp_unused );
329     tmp_called_instance_3 = var_inst;
330  
331     if ( tmp_called_instance_3 == NULL )
332     {
333  
334         exception_type = PyExc_UnboundLocalError;
335         Py_INCREF( exception_type );
336         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
337         exception_tb = NULL;
338         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
339         CHAIN_EXCEPTION( exception_value );
340  
341         exception_lineno = 34;
342         type_description_1 = "o";
343         goto frame_exception_exit_1;
344     }
345  
346     frame_22e26ed2ccfcf999c93f40ab13693c50->m_frame.f_lineno = 34;
347     tmp_unused = CALL_METHOD_WITH_ARGS1( tmp_called_instance_3, const_str_plain_compiled_method, &PyTuple_GET_ITEM( const_tuple_str_plain_some_tuple, 0 ) );
348  
349     if ( tmp_unused == NULL )
350     {
351         assert( ERROR_OCCURRED() );
352  
353         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
354  
355  
356         exception_lineno = 34;
357         type_description_1 = "o";
358         goto frame_exception_exit_1;
359     }
360     Py_DECREF( tmp_unused );
361 270
362 #if 0 271 #if 0
363     RESTORE_FRAME_EXCEPTION( frame_22e26ed2ccfcf999c93f40ab13693c50 ); 272     RESTORE_FRAME_EXCEPTION( frame_22e26ed2ccfcf999c93f40ab13693c50 );
364 #endif 273 #endif
365 274
414     // tried codes exits in all cases 323     // tried codes exits in all cases
415     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly ); 324     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly );
416     return NULL; 325     return NULL;
417     // Return handler code: 326     // Return handler code:
418     try_return_handler_1:; 327     try_return_handler_1:;
n n 328     CHECK_OBJECT( (PyObject *)var_inst );
419     Py_XDECREF( var_inst ); 329     Py_DECREF( var_inst );
420     var_inst = NULL; 330     var_inst = NULL;
421 331
422     goto function_return_exit; 332     goto function_return_exit;
423     // Exception handler code: 333     // Exception handler code:
424     try_except_handler_1:; 334     try_except_handler_1:;
428     exception_keeper_lineno_1 = exception_lineno; 338     exception_keeper_lineno_1 = exception_lineno;
429     exception_type = NULL; 339     exception_type = NULL;
430     exception_value = NULL; 340     exception_value = NULL;
431     exception_tb = NULL; 341     exception_tb = NULL;
432     exception_lineno = 0; 342     exception_lineno = 0;
t 433   t
434     Py_XDECREF( var_inst );
435     var_inst = NULL;
436 343
437     // Re-raise. 344     // Re-raise.
438     exception_type = exception_keeper_type_1; 345     exception_type = exception_keeper_type_1;
439     exception_value = exception_keeper_value_1; 346     exception_value = exception_keeper_value_1;
440     exception_tb = exception_keeper_tb_1; 347     exception_tb = exception_keeper_tb_1;