Construct CallCompiledObjectMethodNoArgs

Performance Diagrams

Construct CallCompiledObjectMethodNoArgs 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)13812073788.11538461538461257.00000000000006CPython 2.728602128240.03846153846155452.94257729436333Nuitka (master)28602344391.96153846153845452.94219084317405Nuitka (develop)28600976543.8846153846154452.94463836737276Nuitka (factory)Construct CallCompiledObjectMethodNoArgsTicks Construct CallCompiledObjectMethodNoArgs 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)13251246588.11538461538461257.0CPython 3.527803070240.03846153846155452.2669314412741Nuitka (master)27809855391.96153846153845452.2542784588953Nuitka (develop)27802446543.8846153846154452.26809510538675Nuitka (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
199     PyObject *exception_keeper_type_1; 199     PyObject *exception_keeper_type_1;
200     PyObject *exception_keeper_value_1; 200     PyObject *exception_keeper_value_1;
201     PyTracebackObject *exception_keeper_tb_1; 201     PyTracebackObject *exception_keeper_tb_1;
202     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 202     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
203     PyObject *tmp_assign_source_1; 203     PyObject *tmp_assign_source_1;
n 204     PyObject *tmp_called_instance_1; n
205     PyObject *tmp_called_instance_2;
206     PyObject *tmp_called_instance_3;
207     PyObject *tmp_called_name_1; 204     PyObject *tmp_called_name_1;
208     PyObject *tmp_return_value; 205     PyObject *tmp_return_value;
n 209     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
210     static struct Nuitka_FrameObject *cache_frame_87474dc3e7e72099d34d294af70508ec = NULL; 206     static struct Nuitka_FrameObject *cache_frame_87474dc3e7e72099d34d294af70508ec = NULL;
211 207
212     struct Nuitka_FrameObject *frame_87474dc3e7e72099d34d294af70508ec; 208     struct Nuitka_FrameObject *frame_87474dc3e7e72099d34d294af70508ec;
213 209
214     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 210     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
262         goto frame_exception_exit_1; 258         goto frame_exception_exit_1;
263     } 259     }
264     assert( var_inst == NULL ); 260     assert( var_inst == NULL );
265     var_inst = tmp_assign_source_1; 261     var_inst = tmp_assign_source_1;
266 262
n 267     tmp_called_instance_1 = var_inst; n
268  
269     CHECK_OBJECT( tmp_called_instance_1 );
270     frame_87474dc3e7e72099d34d294af70508ec->m_frame.f_lineno = 32;
271     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_1, const_str_plain_compiled_method );
272     if ( tmp_unused == NULL )
273     {
274         assert( ERROR_OCCURRED() );
275  
276         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
277  
278  
279         exception_lineno = 32;
280         type_description_1 = "o";
281         goto frame_exception_exit_1;
282     }
283     Py_DECREF( tmp_unused );
284     tmp_called_instance_2 = var_inst;
285  
286     if ( tmp_called_instance_2 == NULL )
287     {
288  
289         exception_type = PyExc_UnboundLocalError;
290         Py_INCREF( exception_type );
291         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
292         exception_tb = NULL;
293         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
294         CHAIN_EXCEPTION( exception_value );
295  
296         exception_lineno = 33;
297         type_description_1 = "o";
298         goto frame_exception_exit_1;
299     }
300  
301     frame_87474dc3e7e72099d34d294af70508ec->m_frame.f_lineno = 33;
302     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_2, const_str_plain_compiled_method );
303     if ( tmp_unused == NULL )
304     {
305         assert( ERROR_OCCURRED() );
306  
307         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
308  
309  
310         exception_lineno = 33;
311         type_description_1 = "o";
312         goto frame_exception_exit_1;
313     }
314     Py_DECREF( tmp_unused );
315     tmp_called_instance_3 = var_inst;
316  
317     if ( tmp_called_instance_3 == NULL )
318     {
319  
320         exception_type = PyExc_UnboundLocalError;
321         Py_INCREF( exception_type );
322         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
323         exception_tb = NULL;
324         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
325         CHAIN_EXCEPTION( exception_value );
326  
327         exception_lineno = 34;
328         type_description_1 = "o";
329         goto frame_exception_exit_1;
330     }
331  
332     frame_87474dc3e7e72099d34d294af70508ec->m_frame.f_lineno = 34;
333     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_3, const_str_plain_compiled_method );
334     if ( tmp_unused == NULL )
335     {
336         assert( ERROR_OCCURRED() );
337  
338         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
339  
340  
341         exception_lineno = 34;
342         type_description_1 = "o";
343         goto frame_exception_exit_1;
344     }
345     Py_DECREF( tmp_unused );
346 263
347 #if 0 264 #if 0
348     RESTORE_FRAME_EXCEPTION( frame_87474dc3e7e72099d34d294af70508ec ); 265     RESTORE_FRAME_EXCEPTION( frame_87474dc3e7e72099d34d294af70508ec );
349 #endif 266 #endif
350 267
399     // tried codes exits in all cases 316     // tried codes exits in all cases
400     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly ); 317     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly );
401     return NULL; 318     return NULL;
402     // Return handler code: 319     // Return handler code:
403     try_return_handler_1:; 320     try_return_handler_1:;
n n 321     CHECK_OBJECT( (PyObject *)var_inst );
404     Py_XDECREF( var_inst ); 322     Py_DECREF( var_inst );
405     var_inst = NULL; 323     var_inst = NULL;
406 324
407     goto function_return_exit; 325     goto function_return_exit;
408     // Exception handler code: 326     // Exception handler code:
409     try_except_handler_1:; 327     try_except_handler_1:;
413     exception_keeper_lineno_1 = exception_lineno; 331     exception_keeper_lineno_1 = exception_lineno;
414     exception_type = NULL; 332     exception_type = NULL;
415     exception_value = NULL; 333     exception_value = NULL;
416     exception_tb = NULL; 334     exception_tb = NULL;
417     exception_lineno = 0; 335     exception_lineno = 0;
t 418   t
419     Py_XDECREF( var_inst );
420     var_inst = NULL;
421 336
422     // Re-raise. 337     // Re-raise.
423     exception_type = exception_keeper_type_1; 338     exception_type = exception_keeper_type_1;
424     exception_value = exception_keeper_value_1; 339     exception_value = exception_keeper_value_1;
425     exception_tb = exception_keeper_tb_1; 340     exception_tb = exception_keeper_tb_1;