Construct CallCompiledObjectMethodNoArgs

Performance Diagrams

Construct CallCompiledObjectMethodNoArgs 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000140000000140000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)14417991888.11538461538461257.0CPython 2.728601552240.03846153846155455.094108829412Nuitka (master)28601258391.96153846153845455.09461272707046Nuitka (develop)28600960543.8846153846154455.09512348047934Nuitka (factory)Construct CallCompiledObjectMethodNoArgsTicks Construct CallCompiledObjectMethodNoArgs 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)13280396988.11538461538461257.0CPython 3.529302034240.03846153846155449.59153674813393Nuitka (master)29304273391.96153846153845449.587370522152Nuitka (develop)29298691543.8846153846154449.5977572454352Nuitka (factory)Construct CallCompiledObjectMethodNoArgsTicks

Source Code with Construct

from __future__ import print_function

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

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()
    inst.compiled_method()
    inst.compiled_method()

# 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):
        return self

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() n 32  
33     inst.compiled_method() 33  
34     inst.compiled_method() 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
275     } 275     }
276     assert( var_inst == NULL ); 276     assert( var_inst == NULL );
277     var_inst = tmp_assign_source_1; 277     var_inst = tmp_assign_source_1;
278 278
279     } 279     }
n 280     { n
281     PyObject *tmp_called_instance_1;
282     PyObject *tmp_call_result_1;
283     CHECK_OBJECT( var_inst );
284     tmp_called_instance_1 = var_inst;
285     frame_c7f806bca6e7f3c16267fdeb8859d87f->m_frame.f_lineno = 32;
286     tmp_call_result_1 = CALL_METHOD_NO_ARGS( tmp_called_instance_1, const_str_plain_compiled_method );
287     if ( tmp_call_result_1 == NULL )
288     {
289         assert( ERROR_OCCURRED() );
290  
291         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
292  
293  
294         exception_lineno = 32;
295         type_description_1 = "o";
296         goto frame_exception_exit_1;
297     }
298     Py_DECREF( tmp_call_result_1 );
299     }
300     {
301     PyObject *tmp_called_instance_2;
302     PyObject *tmp_call_result_2;
303     if ( var_inst == NULL )
304     {
305  
306         exception_type = PyExc_UnboundLocalError;
307         Py_INCREF( exception_type );
308         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
309         exception_tb = NULL;
310         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
311         CHAIN_EXCEPTION( exception_value );
312  
313         exception_lineno = 33;
314         type_description_1 = "o";
315         goto frame_exception_exit_1;
316     }
317  
318     tmp_called_instance_2 = var_inst;
319     frame_c7f806bca6e7f3c16267fdeb8859d87f->m_frame.f_lineno = 33;
320     tmp_call_result_2 = CALL_METHOD_NO_ARGS( tmp_called_instance_2, const_str_plain_compiled_method );
321     if ( tmp_call_result_2 == NULL )
322     {
323         assert( ERROR_OCCURRED() );
324  
325         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
326  
327  
328         exception_lineno = 33;
329         type_description_1 = "o";
330         goto frame_exception_exit_1;
331     }
332     Py_DECREF( tmp_call_result_2 );
333     }
334     {
335     PyObject *tmp_called_instance_3;
336     PyObject *tmp_call_result_3;
337     if ( var_inst == NULL )
338     {
339  
340         exception_type = PyExc_UnboundLocalError;
341         Py_INCREF( exception_type );
342         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
343         exception_tb = NULL;
344         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
345         CHAIN_EXCEPTION( exception_value );
346  
347         exception_lineno = 34;
348         type_description_1 = "o";
349         goto frame_exception_exit_1;
350     }
351  
352     tmp_called_instance_3 = var_inst;
353     frame_c7f806bca6e7f3c16267fdeb8859d87f->m_frame.f_lineno = 34;
354     tmp_call_result_3 = CALL_METHOD_NO_ARGS( tmp_called_instance_3, const_str_plain_compiled_method );
355     if ( tmp_call_result_3 == NULL )
356     {
357         assert( ERROR_OCCURRED() );
358  
359         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
360  
361  
362         exception_lineno = 34;
363         type_description_1 = "o";
364         goto frame_exception_exit_1;
365     }
366     Py_DECREF( tmp_call_result_3 );
367     }
368 280
369 #if 0 281 #if 0
370     RESTORE_FRAME_EXCEPTION( frame_c7f806bca6e7f3c16267fdeb8859d87f ); 282     RESTORE_FRAME_EXCEPTION( frame_c7f806bca6e7f3c16267fdeb8859d87f );
371 #endif 283 #endif
372 284
423     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly ); 335     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly );
424     return NULL; 336     return NULL;
425     // Return handler code: 337     // Return handler code:
426     try_return_handler_1:; 338     try_return_handler_1:;
427     { 339     {
n n 340     CHECK_OBJECT( (PyObject *)var_inst );
428     Py_XDECREF( var_inst ); 341     Py_DECREF( var_inst );
429     var_inst = NULL; 342     var_inst = NULL;
430 343
431     } 344     }
432     { 345     {
433     goto function_return_exit; 346     goto function_return_exit;
441     exception_type = NULL; 354     exception_type = NULL;
442     exception_value = NULL; 355     exception_value = NULL;
443     exception_tb = NULL; 356     exception_tb = NULL;
444     exception_lineno = 0; 357     exception_lineno = 0;
445 358
t 446     { t
447     Py_XDECREF( var_inst );
448     var_inst = NULL;
449  
450     }
451     { 359     {
452     // Re-raise. 360     // Re-raise.
453     exception_type = exception_keeper_type_1; 361     exception_type = exception_keeper_type_1;
454     exception_value = exception_keeper_value_1; 362     exception_value = exception_keeper_value_1;
455     exception_tb = exception_keeper_tb_1; 363     exception_tb = exception_keeper_tb_1;