Construct CallCompiledObjectMethodPosArgsConstant1

Performance Diagrams

Construct CallCompiledObjectMethodPosArgsConstant1 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000140000000140000000150000000150000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)15411118688.11538461538461257.0CPython 2.737901641240.03846153846155443.3405710773899Nuitka (master)37901587391.96153846153845443.34065766572337Nuitka (develop)37901593543.8846153846154443.34064804479743Nuitka (factory)Construct CallCompiledObjectMethodPosArgsConstant1Ticks Construct CallCompiledObjectMethodPosArgsConstant1 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000140000000140000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)14153469988.11538461538461257.0CPython 3.538907070240.03846153846155436.1847949067246Nuitka (master)38898489391.96153846153845436.1997770780958Nuitka (develop)38903549543.8846153846154436.190942468244Nuitka (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
60 static PyObject *const_str_plain_C; 60 static PyObject *const_str_plain_C;
61 extern PyObject *const_tuple_empty; 61 extern PyObject *const_tuple_empty;
62 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352; 62 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352;
63 static PyObject *const_tuple_str_plain_inst_tuple; 63 static PyObject *const_tuple_str_plain_inst_tuple;
64 static PyObject *const_str_plain_repeat; 64 static PyObject *const_str_plain_repeat;
n 65 static PyObject *const_str_plain_some; n
66 static PyObject *const_tuple_none_int_pos_50000_tuple; 65 static PyObject *const_tuple_none_int_pos_50000_tuple;
67 extern PyObject *const_str_plain___main__; 66 extern PyObject *const_str_plain___main__;
n 68 static PyObject *const_tuple_str_plain_some_tuple; n
69 extern PyObject *const_str_plain_type; 67 extern PyObject *const_str_plain_type;
70 extern PyObject *const_str_plain___doc__; 68 extern PyObject *const_str_plain___doc__;
71 extern PyObject *const_str_plain___cached__; 69 extern PyObject *const_str_plain___cached__;
72 static PyObject *const_str_plain_print_function; 70 static PyObject *const_str_plain_print_function;
73 static PyObject *module_filename_obj; 71 static PyObject *module_filename_obj;
107     const_str_plain_None = UNSTREAM_STRING( &constant_bin[ 212 ], 4, 1 ); 105     const_str_plain_None = UNSTREAM_STRING( &constant_bin[ 212 ], 4, 1 );
108     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 115 ], 1, 1 ); 106     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 115 ], 1, 1 );
109     const_tuple_str_plain_inst_tuple = PyTuple_New( 1 ); 107     const_tuple_str_plain_inst_tuple = PyTuple_New( 1 );
110     PyTuple_SET_ITEM( const_tuple_str_plain_inst_tuple, 0, const_str_plain_inst ); Py_INCREF( const_str_plain_inst ); 108     PyTuple_SET_ITEM( const_tuple_str_plain_inst_tuple, 0, const_str_plain_inst ); Py_INCREF( const_str_plain_inst );
111     const_str_plain_repeat = UNSTREAM_STRING( &constant_bin[ 216 ], 6, 1 ); 109     const_str_plain_repeat = UNSTREAM_STRING( &constant_bin[ 216 ], 6, 1 );
n 112     const_str_plain_some = UNSTREAM_STRING( &constant_bin[ 222 ], 4, 1 ); n
113     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 ); 110     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 );
114     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None ); 111     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None );
115     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 ); 112     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 );
n 116     const_tuple_str_plain_some_tuple = PyTuple_New( 1 ); n
117     PyTuple_SET_ITEM( const_tuple_str_plain_some_tuple, 0, const_str_plain_some ); Py_INCREF( const_str_plain_some );
118     const_str_plain_print_function = UNSTREAM_STRING( &constant_bin[ 226 ], 14, 1 ); 113     const_str_plain_print_function = UNSTREAM_STRING( &constant_bin[ 222 ], 14, 1 );
119 114
120     constants_created = true; 115     constants_created = true;
121 } 116 }
122 117
123 #ifndef __NUITKA_NO_ASSERT__ 118 #ifndef __NUITKA_NO_ASSERT__
226     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 221     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
227     PyObject *exception_type = NULL; 222     PyObject *exception_type = NULL;
228     PyObject *exception_value = NULL; 223     PyObject *exception_value = NULL;
229     PyTracebackObject *exception_tb = NULL; 224     PyTracebackObject *exception_tb = NULL;
230     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 225     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n 231     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
232     static struct Nuitka_FrameObject *cache_frame_cededc29c731200833d19ba12ce8e0be = NULL; 226     static struct Nuitka_FrameObject *cache_frame_cededc29c731200833d19ba12ce8e0be = NULL;
233     PyObject *tmp_return_value = NULL; 227     PyObject *tmp_return_value = NULL;
234     PyObject *exception_keeper_type_1; 228     PyObject *exception_keeper_type_1;
235     PyObject *exception_keeper_value_1; 229     PyObject *exception_keeper_value_1;
236     PyTracebackObject *exception_keeper_tb_1; 230     PyTracebackObject *exception_keeper_tb_1;
289     } 283     }
290     assert( var_inst == NULL ); 284     assert( var_inst == NULL );
291     var_inst = tmp_assign_source_1; 285     var_inst = tmp_assign_source_1;
292 286
293     } 287     }
n 294     { n
295     PyObject *tmp_called_instance_1;
296     tmp_called_instance_1 = var_inst;
297  
298     CHECK_OBJECT( tmp_called_instance_1 );
299     frame_cededc29c731200833d19ba12ce8e0be->m_frame.f_lineno = 32;
300     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 ) );
301  
302     if ( tmp_unused == NULL )
303     {
304         assert( ERROR_OCCURRED() );
305  
306         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
307  
308  
309         exception_lineno = 32;
310         type_description_1 = "o";
311         goto frame_exception_exit_1;
312     }
313     Py_DECREF( tmp_unused );
314     }
315     {
316     PyObject *tmp_called_instance_2;
317     tmp_called_instance_2 = var_inst;
318  
319     if ( tmp_called_instance_2 == NULL )
320     {
321  
322         exception_type = PyExc_UnboundLocalError;
323         Py_INCREF( exception_type );
324         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
325         exception_tb = NULL;
326         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
327         CHAIN_EXCEPTION( exception_value );
328  
329         exception_lineno = 33;
330         type_description_1 = "o";
331         goto frame_exception_exit_1;
332     }
333  
334     frame_cededc29c731200833d19ba12ce8e0be->m_frame.f_lineno = 33;
335     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 ) );
336  
337     if ( tmp_unused == NULL )
338     {
339         assert( ERROR_OCCURRED() );
340  
341         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
342  
343  
344         exception_lineno = 33;
345         type_description_1 = "o";
346         goto frame_exception_exit_1;
347     }
348     Py_DECREF( tmp_unused );
349     }
350     {
351     PyObject *tmp_called_instance_3;
352     tmp_called_instance_3 = var_inst;
353  
354     if ( tmp_called_instance_3 == NULL )
355     {
356  
357         exception_type = PyExc_UnboundLocalError;
358         Py_INCREF( exception_type );
359         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
360         exception_tb = NULL;
361         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
362         CHAIN_EXCEPTION( exception_value );
363  
364         exception_lineno = 34;
365         type_description_1 = "o";
366         goto frame_exception_exit_1;
367     }
368  
369     frame_cededc29c731200833d19ba12ce8e0be->m_frame.f_lineno = 34;
370     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 ) );
371  
372     if ( tmp_unused == NULL )
373     {
374         assert( ERROR_OCCURRED() );
375  
376         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
377  
378  
379         exception_lineno = 34;
380         type_description_1 = "o";
381         goto frame_exception_exit_1;
382     }
383     Py_DECREF( tmp_unused );
384     }
385 288
386 #if 0 289 #if 0
387     RESTORE_FRAME_EXCEPTION( frame_cededc29c731200833d19ba12ce8e0be ); 290     RESTORE_FRAME_EXCEPTION( frame_cededc29c731200833d19ba12ce8e0be );
388 #endif 291 #endif
389 292
441     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly ); 344     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly );
442     return NULL; 345     return NULL;
443     // Return handler code: 346     // Return handler code:
444     try_return_handler_1:; 347     try_return_handler_1:;
445     { 348     {
n n 349     CHECK_OBJECT( (PyObject *)var_inst );
446     Py_XDECREF( var_inst ); 350     Py_DECREF( var_inst );
447     var_inst = NULL; 351     var_inst = NULL;
448 352
449     } 353     }
450     { 354     {
451     goto function_return_exit; 355     goto function_return_exit;
459     exception_type = NULL; 363     exception_type = NULL;
460     exception_value = NULL; 364     exception_value = NULL;
461     exception_tb = NULL; 365     exception_tb = NULL;
462     exception_lineno = 0; 366     exception_lineno = 0;
463 367
t 464     { t
465     Py_XDECREF( var_inst );
466     var_inst = NULL;
467  
468     }
469     { 368     {
470     // Re-raise. 369     // Re-raise.
471     exception_type = exception_keeper_type_1; 370     exception_type = exception_keeper_type_1;
472     exception_value = exception_keeper_value_1; 371     exception_value = exception_keeper_value_1;
473     exception_tb = exception_keeper_tb_1; 372     exception_tb = exception_keeper_tb_1;