Construct CallCompiledObjectMethodNoArgs

Performance Diagrams

Construct CallCompiledObjectMethodNoArgs 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000140000000140000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)14417991888.11538461538461257.0CPython 2.728601270240.03846153846155455.09459215981906Nuitka (master)28601042391.96153846153845455.09498293759503Nuitka (develop)28601108543.8846153846154455.0948698177125Nuitka (factory)Construct CallCompiledObjectMethodNoArgsTicks Construct CallCompiledObjectMethodNoArgs 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)13280396988.11538461538461257.0CPython 3.529301806240.03846153846155449.59196099981943Nuitka (master)29301664391.96153846153845449.5922252267464Nuitka (develop)29301942543.8846153846154449.59170793741055Nuitka (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
212     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 212     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
213     PyObject *exception_type = NULL; 213     PyObject *exception_type = NULL;
214     PyObject *exception_value = NULL; 214     PyObject *exception_value = NULL;
215     PyTracebackObject *exception_tb = NULL; 215     PyTracebackObject *exception_tb = NULL;
216     NUITKA_MAY_BE_UNUSED int exception_lineno = 0; 216     NUITKA_MAY_BE_UNUSED int exception_lineno = 0;
n 217     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
218     static struct Nuitka_FrameObject *cache_frame_23263178fd328b21889a17e8cd9b0d21 = NULL; 217     static struct Nuitka_FrameObject *cache_frame_23263178fd328b21889a17e8cd9b0d21 = NULL;
219     PyObject *tmp_return_value = NULL; 218     PyObject *tmp_return_value = NULL;
220     PyObject *exception_keeper_type_1; 219     PyObject *exception_keeper_type_1;
221     PyObject *exception_keeper_value_1; 220     PyObject *exception_keeper_value_1;
222     PyTracebackObject *exception_keeper_tb_1; 221     PyTracebackObject *exception_keeper_tb_1;
275     } 274     }
276     assert( var_inst == NULL ); 275     assert( var_inst == NULL );
277     var_inst = tmp_assign_source_1; 276     var_inst = tmp_assign_source_1;
278 277
279     } 278     }
n 280     { n
281     PyObject *tmp_called_instance_1;
282     tmp_called_instance_1 = var_inst;
283  
284     CHECK_OBJECT( tmp_called_instance_1 );
285     frame_23263178fd328b21889a17e8cd9b0d21->m_frame.f_lineno = 32;
286     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_1, const_str_plain_compiled_method );
287     if ( tmp_unused == 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_unused );
299     }
300     {
301     PyObject *tmp_called_instance_2;
302     tmp_called_instance_2 = var_inst;
303  
304     if ( tmp_called_instance_2 == NULL )
305     {
306  
307         exception_type = PyExc_UnboundLocalError;
308         Py_INCREF( exception_type );
309         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
310         exception_tb = NULL;
311         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
312         CHAIN_EXCEPTION( exception_value );
313  
314         exception_lineno = 33;
315         type_description_1 = "o";
316         goto frame_exception_exit_1;
317     }
318  
319     frame_23263178fd328b21889a17e8cd9b0d21->m_frame.f_lineno = 33;
320     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_2, const_str_plain_compiled_method );
321     if ( tmp_unused == 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_unused );
333     }
334     {
335     PyObject *tmp_called_instance_3;
336     tmp_called_instance_3 = var_inst;
337  
338     if ( tmp_called_instance_3 == NULL )
339     {
340  
341         exception_type = PyExc_UnboundLocalError;
342         Py_INCREF( exception_type );
343         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
344         exception_tb = NULL;
345         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
346         CHAIN_EXCEPTION( exception_value );
347  
348         exception_lineno = 34;
349         type_description_1 = "o";
350         goto frame_exception_exit_1;
351     }
352  
353     frame_23263178fd328b21889a17e8cd9b0d21->m_frame.f_lineno = 34;
354     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_3, const_str_plain_compiled_method );
355     if ( tmp_unused == 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_unused );
367     }
368 279
369 #if 0 280 #if 0
370     RESTORE_FRAME_EXCEPTION( frame_23263178fd328b21889a17e8cd9b0d21 ); 281     RESTORE_FRAME_EXCEPTION( frame_23263178fd328b21889a17e8cd9b0d21 );
371 #endif 282 #endif
372 283
424     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly ); 335     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly );
425     return NULL; 336     return NULL;
426     // Return handler code: 337     // Return handler code:
427     try_return_handler_1:; 338     try_return_handler_1:;
428     { 339     {
n n 340     CHECK_OBJECT( (PyObject *)var_inst );
429     Py_XDECREF( var_inst ); 341     Py_DECREF( var_inst );
430     var_inst = NULL; 342     var_inst = NULL;
431 343
432     } 344     }
433     { 345     {
434     goto function_return_exit; 346     goto function_return_exit;
442     exception_type = NULL; 354     exception_type = NULL;
443     exception_value = NULL; 355     exception_value = NULL;
444     exception_tb = NULL; 356     exception_tb = NULL;
445     exception_lineno = 0; 357     exception_lineno = 0;
446 358
t 447     { t
448     Py_XDECREF( var_inst );
449     var_inst = NULL;
450  
451     }
452     { 359     {
453     // Re-raise. 360     // Re-raise.
454     exception_type = exception_keeper_type_1; 361     exception_type = exception_keeper_type_1;
455     exception_value = exception_keeper_value_1; 362     exception_value = exception_keeper_value_1;
456     exception_tb = exception_keeper_tb_1; 363     exception_tb = exception_keeper_tb_1;