Construct CallCompiledObjectMethodNoArgs

Performance Diagrams

Construct CallCompiledObjectMethodNoArgs 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)13812050072.9230769230769257.0CPython 2.752150341194.46153846153845410.8116999774166Nuitka (historic)28653389316.0452.8507769483893Nuitka (master)28652645437.53846153846143452.85210806032524Nuitka (develop)28652657559.0769230769231452.8520865907779Nuitka (factory)Construct CallCompiledObjectMethodNoArgsTicks Construct CallCompiledObjectMethodNoArgs 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)13251131672.9230769230769257.0CPython 3.50194.46153846153845504.11538461538464Nuitka (historic)27876216316.0452.13007463279007Nuitka (master)27898087437.53846153846143452.08928822495665Nuitka (develop)27897259559.0769230769231452.0908323311103Nuitka (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



for x in xrange(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

for x in xrange(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 for x in xrange(50000): 40 for x in xrange(50000):
41     calledRepeatedly() 41     calledRepeatedly()
42 42
43 print("OK.") 43 print("OK.")

Context Diff of Generated Code


Construct
Baseline
398     PyObject *exception_keeper_type_1; 398     PyObject *exception_keeper_type_1;
399     PyObject *exception_keeper_value_1; 399     PyObject *exception_keeper_value_1;
400     PyTracebackObject *exception_keeper_tb_1; 400     PyTracebackObject *exception_keeper_tb_1;
401     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 401     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
402     PyObject *tmp_assign_source_1; 402     PyObject *tmp_assign_source_1;
n 403     PyObject *tmp_called_instance_1; n
404     PyObject *tmp_called_instance_2;
405     PyObject *tmp_called_instance_3;
406     PyObject *tmp_called_name_1; 403     PyObject *tmp_called_name_1;
407     PyObject *tmp_frame_locals; 404     PyObject *tmp_frame_locals;
408     PyObject *tmp_return_value; 405     PyObject *tmp_return_value;
n 409     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
410     static PyFrameObject *cache_frame_function = NULL; 406     static PyFrameObject *cache_frame_function = NULL;
411 407
412     PyFrameObject *frame_function; 408     PyFrameObject *frame_function;
413 409
414     tmp_return_value = NULL; 410     tmp_return_value = NULL;
464         goto frame_exception_exit_1; 460         goto frame_exception_exit_1;
465     } 461     }
466     assert( var_inst == NULL ); 462     assert( var_inst == NULL );
467     var_inst = tmp_assign_source_1; 463     var_inst = tmp_assign_source_1;
468 464
n 469     tmp_called_instance_1 = var_inst; n
470  
471     frame_function->f_lineno = 32;
472     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_1, const_str_plain_compiled_method );
473     if ( tmp_unused == NULL )
474     {
475         assert( ERROR_OCCURRED() );
476  
477         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
478  
479  
480         exception_lineno = 32;
481         goto frame_exception_exit_1;
482     }
483     Py_DECREF( tmp_unused );
484     tmp_called_instance_2 = var_inst;
485  
486     if ( tmp_called_instance_2 == NULL )
487     {
488  
489         exception_type = PyExc_UnboundLocalError;
490         Py_INCREF( exception_type );
491         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
492         exception_tb = NULL;
493         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
494         CHAIN_EXCEPTION( exception_value );
495  
496         exception_lineno = 33;
497         goto frame_exception_exit_1;
498     }
499  
500     frame_function->f_lineno = 33;
501     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_2, const_str_plain_compiled_method );
502     if ( tmp_unused == NULL )
503     {
504         assert( ERROR_OCCURRED() );
505  
506         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
507  
508  
509         exception_lineno = 33;
510         goto frame_exception_exit_1;
511     }
512     Py_DECREF( tmp_unused );
513     tmp_called_instance_3 = var_inst;
514  
515     if ( tmp_called_instance_3 == NULL )
516     {
517  
518         exception_type = PyExc_UnboundLocalError;
519         Py_INCREF( exception_type );
520         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
521         exception_tb = NULL;
522         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
523         CHAIN_EXCEPTION( exception_value );
524  
525         exception_lineno = 34;
526         goto frame_exception_exit_1;
527     }
528  
529     frame_function->f_lineno = 34;
530     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_3, const_str_plain_compiled_method );
531     if ( tmp_unused == NULL )
532     {
533         assert( ERROR_OCCURRED() );
534  
535         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
536  
537  
538         exception_lineno = 34;
539         goto frame_exception_exit_1;
540     }
541     Py_DECREF( tmp_unused );
542 465
543 #if 0 466 #if 0
544     RESTORE_FRAME_EXCEPTION( frame_function ); 467     RESTORE_FRAME_EXCEPTION( frame_function );
545 #endif 468 #endif
546     // Put the previous frame back on top. 469     // Put the previous frame back on top.
612     // tried codes exits in all cases 535     // tried codes exits in all cases
613     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 536     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
614     return NULL; 537     return NULL;
615     // Return handler code: 538     // Return handler code:
616     try_return_handler_1:; 539     try_return_handler_1:;
n n 540     CHECK_OBJECT( (PyObject *)var_inst );
617     Py_XDECREF( var_inst ); 541     Py_DECREF( var_inst );
618     var_inst = NULL; 542     var_inst = NULL;
619 543
620     goto function_return_exit; 544     goto function_return_exit;
621     // Exception handler code: 545     // Exception handler code:
622     try_except_handler_1:; 546     try_except_handler_1:;
626     exception_keeper_lineno_1 = exception_lineno; 550     exception_keeper_lineno_1 = exception_lineno;
627     exception_type = NULL; 551     exception_type = NULL;
628     exception_value = NULL; 552     exception_value = NULL;
629     exception_tb = NULL; 553     exception_tb = NULL;
630     exception_lineno = -1; 554     exception_lineno = -1;
t 631   t
632     Py_XDECREF( var_inst );
633     var_inst = NULL;
634 555
635     // Re-raise. 556     // Re-raise.
636     exception_type = exception_keeper_type_1; 557     exception_type = exception_keeper_type_1;
637     exception_value = exception_keeper_value_1; 558     exception_value = exception_keeper_value_1;
638     exception_tb = exception_keeper_tb_1; 559     exception_tb = exception_keeper_tb_1;