Construct CallCompiledObjectMethodNoArgs

Performance Diagrams

Construct CallCompiledObjectMethodNoArgs 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)13812073788.11538461538461257.00000000000006CPython 2.728601051240.03846153846155452.94450418293206Nuitka (master)28602078391.96153846153845452.9426667506571Nuitka (develop)28602068543.8846153846154452.9426846419159Nuitka (factory)Construct CallCompiledObjectMethodNoArgsTicks Construct CallCompiledObjectMethodNoArgs 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)13251246588.11538461538461257.0CPython 3.527797823240.03846153846155452.27671628999065Nuitka (master)27800159391.96153846153845452.27236000895346Nuitka (develop)27810103543.8846153846154452.25381597700436Nuitka (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
508     PyObject *exception_keeper_type_1; 508     PyObject *exception_keeper_type_1;
509     PyObject *exception_keeper_value_1; 509     PyObject *exception_keeper_value_1;
510     PyTracebackObject *exception_keeper_tb_1; 510     PyTracebackObject *exception_keeper_tb_1;
511     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 511     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
512     PyObject *tmp_assign_source_1; 512     PyObject *tmp_assign_source_1;
n 513     PyObject *tmp_called_instance_1; n
514     PyObject *tmp_called_instance_2;
515     PyObject *tmp_called_instance_3;
516     PyObject *tmp_called_name_1; 513     PyObject *tmp_called_name_1;
517     PyObject *tmp_return_value; 514     PyObject *tmp_return_value;
n 518     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
519     static struct Nuitka_FrameObject *cache_frame_c8aef63308443af5f5dad59f1ffe35fe = NULL; 515     static struct Nuitka_FrameObject *cache_frame_c8aef63308443af5f5dad59f1ffe35fe = NULL;
520 516
521     struct Nuitka_FrameObject *frame_c8aef63308443af5f5dad59f1ffe35fe; 517     struct Nuitka_FrameObject *frame_c8aef63308443af5f5dad59f1ffe35fe;
522 518
523     char const *type_description; 519     char const *type_description;
571         goto frame_exception_exit_1; 567         goto frame_exception_exit_1;
572     } 568     }
573     assert( var_inst == NULL ); 569     assert( var_inst == NULL );
574     var_inst = tmp_assign_source_1; 570     var_inst = tmp_assign_source_1;
575 571
n 576     tmp_called_instance_1 = var_inst; n
577  
578     CHECK_OBJECT( tmp_called_instance_1 );
579     frame_c8aef63308443af5f5dad59f1ffe35fe->m_frame.f_lineno = 32;
580     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_1, const_str_plain_compiled_method );
581     if ( tmp_unused == NULL )
582     {
583         assert( ERROR_OCCURRED() );
584  
585         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
586  
587  
588         exception_lineno = 32;
589         type_description = "o";
590         goto frame_exception_exit_1;
591     }
592     Py_DECREF( tmp_unused );
593     tmp_called_instance_2 = var_inst;
594  
595     if ( tmp_called_instance_2 == NULL )
596     {
597  
598         exception_type = PyExc_UnboundLocalError;
599         Py_INCREF( exception_type );
600         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
601         exception_tb = NULL;
602         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
603         CHAIN_EXCEPTION( exception_value );
604  
605         exception_lineno = 33;
606         type_description = "o";
607         goto frame_exception_exit_1;
608     }
609  
610     frame_c8aef63308443af5f5dad59f1ffe35fe->m_frame.f_lineno = 33;
611     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_2, const_str_plain_compiled_method );
612     if ( tmp_unused == NULL )
613     {
614         assert( ERROR_OCCURRED() );
615  
616         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
617  
618  
619         exception_lineno = 33;
620         type_description = "o";
621         goto frame_exception_exit_1;
622     }
623     Py_DECREF( tmp_unused );
624     tmp_called_instance_3 = var_inst;
625  
626     if ( tmp_called_instance_3 == NULL )
627     {
628  
629         exception_type = PyExc_UnboundLocalError;
630         Py_INCREF( exception_type );
631         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
632         exception_tb = NULL;
633         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
634         CHAIN_EXCEPTION( exception_value );
635  
636         exception_lineno = 34;
637         type_description = "o";
638         goto frame_exception_exit_1;
639     }
640  
641     frame_c8aef63308443af5f5dad59f1ffe35fe->m_frame.f_lineno = 34;
642     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_3, const_str_plain_compiled_method );
643     if ( tmp_unused == NULL )
644     {
645         assert( ERROR_OCCURRED() );
646  
647         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
648  
649  
650         exception_lineno = 34;
651         type_description = "o";
652         goto frame_exception_exit_1;
653     }
654     Py_DECREF( tmp_unused );
655 572
656 #if 0 573 #if 0
657     RESTORE_FRAME_EXCEPTION( frame_c8aef63308443af5f5dad59f1ffe35fe ); 574     RESTORE_FRAME_EXCEPTION( frame_c8aef63308443af5f5dad59f1ffe35fe );
658 #endif 575 #endif
659 576
703     // tried codes exits in all cases 620     // tried codes exits in all cases
704     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 621     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
705     return NULL; 622     return NULL;
706     // Return handler code: 623     // Return handler code:
707     try_return_handler_1:; 624     try_return_handler_1:;
n n 625     CHECK_OBJECT( (PyObject *)var_inst );
708     Py_XDECREF( var_inst ); 626     Py_DECREF( var_inst );
709     var_inst = NULL; 627     var_inst = NULL;
710 628
711     goto function_return_exit; 629     goto function_return_exit;
712     // Exception handler code: 630     // Exception handler code:
713     try_except_handler_1:; 631     try_except_handler_1:;
717     exception_keeper_lineno_1 = exception_lineno; 635     exception_keeper_lineno_1 = exception_lineno;
718     exception_type = NULL; 636     exception_type = NULL;
719     exception_value = NULL; 637     exception_value = NULL;
720     exception_tb = NULL; 638     exception_tb = NULL;
721     exception_lineno = 0; 639     exception_lineno = 0;
t 722   t
723     Py_XDECREF( var_inst );
724     var_inst = NULL;
725 640
726     // Re-raise. 641     // Re-raise.
727     exception_type = exception_keeper_type_1; 642     exception_type = exception_keeper_type_1;
728     exception_value = exception_keeper_value_1; 643     exception_value = exception_keeper_value_1;
729     exception_tb = exception_keeper_tb_1; 644     exception_tb = exception_keeper_tb_1;