Construct CallCompiledObjectMethodNoArgs

Performance Diagrams

Construct CallCompiledObjectMethodNoArgs 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000140000000140000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)14417984688.11538461538461257.0CPython 2.728601308240.03846153846155455.0945025503346Nuitka (master)28600964391.96153846153845455.09509214516817Nuitka (develop)28601084543.8846153846154455.0948864725518Nuitka (factory)Construct CallCompiledObjectMethodNoArgsTicks Construct CallCompiledObjectMethodNoArgs 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)13280604188.11538461538461257.0CPython 3.529301338240.03846153846155449.5936824767343Nuitka (master)29303424391.96153846153845449.5898010065208Nuitka (develop)29303484543.8846153846154449.5896893630823Nuitka (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
209     PyObject *exception_keeper_type_1; 209     PyObject *exception_keeper_type_1;
210     PyObject *exception_keeper_value_1; 210     PyObject *exception_keeper_value_1;
211     PyTracebackObject *exception_keeper_tb_1; 211     PyTracebackObject *exception_keeper_tb_1;
212     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 212     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
213     PyObject *tmp_assign_source_1; 213     PyObject *tmp_assign_source_1;
n 214     PyObject *tmp_called_instance_1; n
215     PyObject *tmp_called_instance_2;
216     PyObject *tmp_called_instance_3;
217     PyObject *tmp_called_name_1; 214     PyObject *tmp_called_name_1;
218     PyObject *tmp_return_value; 215     PyObject *tmp_return_value;
n 219     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
220     static struct Nuitka_FrameObject *cache_frame_d6ceead2399d3f21f028cbbe05fde366 = NULL; 216     static struct Nuitka_FrameObject *cache_frame_d6ceead2399d3f21f028cbbe05fde366 = NULL;
221 217
222     struct Nuitka_FrameObject *frame_d6ceead2399d3f21f028cbbe05fde366; 218     struct Nuitka_FrameObject *frame_d6ceead2399d3f21f028cbbe05fde366;
223 219
224     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 220     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
272         goto frame_exception_exit_1; 268         goto frame_exception_exit_1;
273     } 269     }
274     assert( var_inst == NULL ); 270     assert( var_inst == NULL );
275     var_inst = tmp_assign_source_1; 271     var_inst = tmp_assign_source_1;
276 272
n 277     tmp_called_instance_1 = var_inst; n
278  
279     CHECK_OBJECT( tmp_called_instance_1 );
280     frame_d6ceead2399d3f21f028cbbe05fde366->m_frame.f_lineno = 32;
281     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_1, const_str_plain_compiled_method );
282     if ( tmp_unused == NULL )
283     {
284         assert( ERROR_OCCURRED() );
285  
286         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
287  
288  
289         exception_lineno = 32;
290         type_description_1 = "o";
291         goto frame_exception_exit_1;
292     }
293     Py_DECREF( tmp_unused );
294     tmp_called_instance_2 = var_inst;
295  
296     if ( tmp_called_instance_2 == NULL )
297     {
298  
299         exception_type = PyExc_UnboundLocalError;
300         Py_INCREF( exception_type );
301         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
302         exception_tb = NULL;
303         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
304         CHAIN_EXCEPTION( exception_value );
305  
306         exception_lineno = 33;
307         type_description_1 = "o";
308         goto frame_exception_exit_1;
309     }
310  
311     frame_d6ceead2399d3f21f028cbbe05fde366->m_frame.f_lineno = 33;
312     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_2, const_str_plain_compiled_method );
313     if ( tmp_unused == NULL )
314     {
315         assert( ERROR_OCCURRED() );
316  
317         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
318  
319  
320         exception_lineno = 33;
321         type_description_1 = "o";
322         goto frame_exception_exit_1;
323     }
324     Py_DECREF( tmp_unused );
325     tmp_called_instance_3 = var_inst;
326  
327     if ( tmp_called_instance_3 == NULL )
328     {
329  
330         exception_type = PyExc_UnboundLocalError;
331         Py_INCREF( exception_type );
332         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
333         exception_tb = NULL;
334         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
335         CHAIN_EXCEPTION( exception_value );
336  
337         exception_lineno = 34;
338         type_description_1 = "o";
339         goto frame_exception_exit_1;
340     }
341  
342     frame_d6ceead2399d3f21f028cbbe05fde366->m_frame.f_lineno = 34;
343     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_3, const_str_plain_compiled_method );
344     if ( tmp_unused == NULL )
345     {
346         assert( ERROR_OCCURRED() );
347  
348         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
349  
350  
351         exception_lineno = 34;
352         type_description_1 = "o";
353         goto frame_exception_exit_1;
354     }
355     Py_DECREF( tmp_unused );
356 273
357 #if 0 274 #if 0
358     RESTORE_FRAME_EXCEPTION( frame_d6ceead2399d3f21f028cbbe05fde366 ); 275     RESTORE_FRAME_EXCEPTION( frame_d6ceead2399d3f21f028cbbe05fde366 );
359 #endif 276 #endif
360 277
409     // tried codes exits in all cases 326     // tried codes exits in all cases
410     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly ); 327     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly );
411     return NULL; 328     return NULL;
412     // Return handler code: 329     // Return handler code:
413     try_return_handler_1:; 330     try_return_handler_1:;
n n 331     CHECK_OBJECT( (PyObject *)var_inst );
414     Py_XDECREF( var_inst ); 332     Py_DECREF( var_inst );
415     var_inst = NULL; 333     var_inst = NULL;
416 334
417     goto function_return_exit; 335     goto function_return_exit;
418     // Exception handler code: 336     // Exception handler code:
419     try_except_handler_1:; 337     try_except_handler_1:;
423     exception_keeper_lineno_1 = exception_lineno; 341     exception_keeper_lineno_1 = exception_lineno;
424     exception_type = NULL; 342     exception_type = NULL;
425     exception_value = NULL; 343     exception_value = NULL;
426     exception_tb = NULL; 344     exception_tb = NULL;
427     exception_lineno = 0; 345     exception_lineno = 0;
t 428   t
429     Py_XDECREF( var_inst );
430     var_inst = NULL;
431 346
432     // Re-raise. 347     // Re-raise.
433     exception_type = exception_keeper_type_1; 348     exception_type = exception_keeper_type_1;
434     exception_value = exception_keeper_value_1; 349     exception_value = exception_keeper_value_1;
435     exception_tb = exception_keeper_tb_1; 350     exception_tb = exception_keeper_tb_1;