Construct CallCompiledObjectMethodPosArgsConstant1

Performance Diagrams

Construct CallCompiledObjectMethodPosArgsConstant1 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000140000000140000000150000000150000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)15411128888.11538461538461257.0CPython 2.738651533240.03846153846155442.1381695312486Nuitka (master)38651593391.96153846153845442.13807332205283Nuitka (develop)38651629543.8846153846154442.13801559653535Nuitka (factory)Construct CallCompiledObjectMethodPosArgsConstant1Ticks Construct CallCompiledObjectMethodPosArgsConstant1 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000140000000140000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)14153479988.11538461538461257.0CPython 3.538907102240.03846153846155436.18478703139397Nuitka (master)38896939391.96153846153845436.20253131528455Nuitka (develop)38901279543.8846153846154436.1949538094216Nuitka (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
61 static PyObject *const_str_plain_C; 61 static PyObject *const_str_plain_C;
62 extern PyObject *const_tuple_empty; 62 extern PyObject *const_tuple_empty;
63 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352; 63 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352;
64 static PyObject *const_tuple_str_plain_inst_tuple; 64 static PyObject *const_tuple_str_plain_inst_tuple;
65 static PyObject *const_str_plain_repeat; 65 static PyObject *const_str_plain_repeat;
n 66 static PyObject *const_str_plain_some; n
67 static PyObject *const_tuple_none_int_pos_50000_tuple; 66 static PyObject *const_tuple_none_int_pos_50000_tuple;
68 extern PyObject *const_str_plain___loader__; 67 extern PyObject *const_str_plain___loader__;
69 extern PyObject *const_str_plain___main__; 68 extern PyObject *const_str_plain___main__;
n 70 static PyObject *const_tuple_str_plain_some_tuple; n
71 extern PyObject *const_str_plain___doc__; 69 extern PyObject *const_str_plain___doc__;
72 extern PyObject *const_str_plain___cached__; 70 extern PyObject *const_str_plain___cached__;
73 static PyObject *const_str_plain_print_function; 71 static PyObject *const_str_plain_print_function;
74 static PyObject *module_filename_obj; 72 static PyObject *module_filename_obj;
75 73
108     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 217 ], 8, 0 ); 106     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 217 ], 8, 0 );
109     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 94 ], 1, 1 ); 107     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 94 ], 1, 1 );
110     const_tuple_str_plain_inst_tuple = PyTuple_New( 1 ); 108     const_tuple_str_plain_inst_tuple = PyTuple_New( 1 );
111     PyTuple_SET_ITEM( const_tuple_str_plain_inst_tuple, 0, const_str_plain_inst ); Py_INCREF( const_str_plain_inst ); 109     PyTuple_SET_ITEM( const_tuple_str_plain_inst_tuple, 0, const_str_plain_inst ); Py_INCREF( const_str_plain_inst );
112     const_str_plain_repeat = UNSTREAM_STRING( &constant_bin[ 225 ], 6, 1 ); 110     const_str_plain_repeat = UNSTREAM_STRING( &constant_bin[ 225 ], 6, 1 );
n 113     const_str_plain_some = UNSTREAM_STRING( &constant_bin[ 231 ], 4, 1 ); n
114     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 ); 111     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 );
115     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None ); 112     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None );
116     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 ); 113     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 );
n 117     const_tuple_str_plain_some_tuple = PyTuple_New( 1 ); n
118     PyTuple_SET_ITEM( const_tuple_str_plain_some_tuple, 0, const_str_plain_some ); Py_INCREF( const_str_plain_some );
119     const_str_plain_print_function = UNSTREAM_STRING( &constant_bin[ 235 ], 14, 1 ); 114     const_str_plain_print_function = UNSTREAM_STRING( &constant_bin[ 231 ], 14, 1 );
120 115
121     constants_created = true; 116     constants_created = true;
122 } 117 }
123 118
124 #ifndef __NUITKA_NO_ASSERT__ 119 #ifndef __NUITKA_NO_ASSERT__
221     PyObject *exception_keeper_type_1; 216     PyObject *exception_keeper_type_1;
222     PyObject *exception_keeper_value_1; 217     PyObject *exception_keeper_value_1;
223     PyTracebackObject *exception_keeper_tb_1; 218     PyTracebackObject *exception_keeper_tb_1;
224     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 219     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
225     PyObject *tmp_assign_source_1; 220     PyObject *tmp_assign_source_1;
n 226     PyObject *tmp_called_instance_1; n
227     PyObject *tmp_called_instance_2;
228     PyObject *tmp_called_instance_3;
229     PyObject *tmp_called_name_1; 221     PyObject *tmp_called_name_1;
230     PyObject *tmp_return_value; 222     PyObject *tmp_return_value;
n 231     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
232     static struct Nuitka_FrameObject *cache_frame_3c585d8bef375dd0c3f4161b3e0d75f6 = NULL; 223     static struct Nuitka_FrameObject *cache_frame_3c585d8bef375dd0c3f4161b3e0d75f6 = NULL;
233 224
234     struct Nuitka_FrameObject *frame_3c585d8bef375dd0c3f4161b3e0d75f6; 225     struct Nuitka_FrameObject *frame_3c585d8bef375dd0c3f4161b3e0d75f6;
235 226
236     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 227     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
284         goto frame_exception_exit_1; 275         goto frame_exception_exit_1;
285     } 276     }
286     assert( var_inst == NULL ); 277     assert( var_inst == NULL );
287     var_inst = tmp_assign_source_1; 278     var_inst = tmp_assign_source_1;
288 279
n 289     tmp_called_instance_1 = var_inst; n
290  
291     CHECK_OBJECT( tmp_called_instance_1 );
292     frame_3c585d8bef375dd0c3f4161b3e0d75f6->m_frame.f_lineno = 32;
293     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 ) );
294  
295     if ( tmp_unused == NULL )
296     {
297         assert( ERROR_OCCURRED() );
298  
299         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
300  
301  
302         exception_lineno = 32;
303         type_description_1 = "o";
304         goto frame_exception_exit_1;
305     }
306     Py_DECREF( tmp_unused );
307     tmp_called_instance_2 = var_inst;
308  
309     if ( tmp_called_instance_2 == NULL )
310     {
311  
312         exception_type = PyExc_UnboundLocalError;
313         Py_INCREF( exception_type );
314         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
315         exception_tb = NULL;
316         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
317         CHAIN_EXCEPTION( exception_value );
318  
319         exception_lineno = 33;
320         type_description_1 = "o";
321         goto frame_exception_exit_1;
322     }
323  
324     frame_3c585d8bef375dd0c3f4161b3e0d75f6->m_frame.f_lineno = 33;
325     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 ) );
326  
327     if ( tmp_unused == NULL )
328     {
329         assert( ERROR_OCCURRED() );
330  
331         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
332  
333  
334         exception_lineno = 33;
335         type_description_1 = "o";
336         goto frame_exception_exit_1;
337     }
338     Py_DECREF( tmp_unused );
339     tmp_called_instance_3 = var_inst;
340  
341     if ( tmp_called_instance_3 == NULL )
342     {
343  
344         exception_type = PyExc_UnboundLocalError;
345         Py_INCREF( exception_type );
346         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
347         exception_tb = NULL;
348         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
349         CHAIN_EXCEPTION( exception_value );
350  
351         exception_lineno = 34;
352         type_description_1 = "o";
353         goto frame_exception_exit_1;
354     }
355  
356     frame_3c585d8bef375dd0c3f4161b3e0d75f6->m_frame.f_lineno = 34;
357     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 ) );
358  
359     if ( tmp_unused == NULL )
360     {
361         assert( ERROR_OCCURRED() );
362  
363         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
364  
365  
366         exception_lineno = 34;
367         type_description_1 = "o";
368         goto frame_exception_exit_1;
369     }
370     Py_DECREF( tmp_unused );
371 280
372 #if 0 281 #if 0
373     RESTORE_FRAME_EXCEPTION( frame_3c585d8bef375dd0c3f4161b3e0d75f6 ); 282     RESTORE_FRAME_EXCEPTION( frame_3c585d8bef375dd0c3f4161b3e0d75f6 );
374 #endif 283 #endif
375 284
424     // tried codes exits in all cases 333     // tried codes exits in all cases
425     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly ); 334     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly );
426     return NULL; 335     return NULL;
427     // Return handler code: 336     // Return handler code:
428     try_return_handler_1:; 337     try_return_handler_1:;
n n 338     CHECK_OBJECT( (PyObject *)var_inst );
429     Py_XDECREF( var_inst ); 339     Py_DECREF( var_inst );
430     var_inst = NULL; 340     var_inst = NULL;
431 341
432     goto function_return_exit; 342     goto function_return_exit;
433     // Exception handler code: 343     // Exception handler code:
434     try_except_handler_1:; 344     try_except_handler_1:;
438     exception_keeper_lineno_1 = exception_lineno; 348     exception_keeper_lineno_1 = exception_lineno;
439     exception_type = NULL; 349     exception_type = NULL;
440     exception_value = NULL; 350     exception_value = NULL;
441     exception_tb = NULL; 351     exception_tb = NULL;
442     exception_lineno = 0; 352     exception_lineno = 0;
t 443   t
444     Py_XDECREF( var_inst );
445     var_inst = NULL;
446 353
447     // Re-raise. 354     // Re-raise.
448     exception_type = exception_keeper_type_1; 355     exception_type = exception_keeper_type_1;
449     exception_value = exception_keeper_value_1; 356     exception_value = exception_keeper_value_1;
450     exception_tb = exception_keeper_tb_1; 357     exception_tb = exception_keeper_tb_1;