Construct CallCompiledObjectMethodNoArgs

Performance Diagrams

Construct CallCompiledObjectMethodNoArgs 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)13812050072.9230769230769257.0CPython 2.752150341194.46153846153845410.8116999774166Nuitka (historic)28602627316.0452.94159671195695Nuitka (master)28603015437.53846153846143452.9409025299258Nuitka (develop)28603003559.0769230769231452.94092399947317Nuitka (factory)Construct CallCompiledObjectMethodNoArgsTicks Construct CallCompiledObjectMethodNoArgs 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)13251131672.9230769230769257.0CPython 3.50194.46153846153845504.11538461538464Nuitka (historic)27802029316.0452.2684231874031Nuitka (master)27802094437.53846153846143452.2683019713403Nuitka (develop)27801531559.0769230769231452.26935188893026Nuitka (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
496     PyObject *exception_keeper_type_1; 496     PyObject *exception_keeper_type_1;
497     PyObject *exception_keeper_value_1; 497     PyObject *exception_keeper_value_1;
498     PyTracebackObject *exception_keeper_tb_1; 498     PyTracebackObject *exception_keeper_tb_1;
499     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 499     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
500     PyObject *tmp_assign_source_1; 500     PyObject *tmp_assign_source_1;
n 501     PyObject *tmp_called_instance_1; n
502     PyObject *tmp_called_instance_2;
503     PyObject *tmp_called_instance_3;
504     PyObject *tmp_called_name_1; 501     PyObject *tmp_called_name_1;
505     PyObject *tmp_return_value; 502     PyObject *tmp_return_value;
n 506     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
507     static struct Nuitka_FrameObject *cache_frame_c24fecb2b4c7ae2ff72032bfaa9232c9 = NULL; 503     static struct Nuitka_FrameObject *cache_frame_c24fecb2b4c7ae2ff72032bfaa9232c9 = NULL;
508 504
509     struct Nuitka_FrameObject *frame_c24fecb2b4c7ae2ff72032bfaa9232c9; 505     struct Nuitka_FrameObject *frame_c24fecb2b4c7ae2ff72032bfaa9232c9;
510 506
511     char const *type_description; 507     char const *type_description;
559         goto frame_exception_exit_1; 555         goto frame_exception_exit_1;
560     } 556     }
561     assert( var_inst == NULL ); 557     assert( var_inst == NULL );
562     var_inst = tmp_assign_source_1; 558     var_inst = tmp_assign_source_1;
563 559
n 564     tmp_called_instance_1 = var_inst; n
565  
566     CHECK_OBJECT( tmp_called_instance_1 );
567     frame_c24fecb2b4c7ae2ff72032bfaa9232c9->m_frame.f_lineno = 32;
568     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_1, const_str_plain_compiled_method );
569     if ( tmp_unused == NULL )
570     {
571         assert( ERROR_OCCURRED() );
572  
573         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
574  
575  
576         exception_lineno = 32;
577         type_description = "o";
578         goto frame_exception_exit_1;
579     }
580     Py_DECREF( tmp_unused );
581     tmp_called_instance_2 = var_inst;
582  
583     if ( tmp_called_instance_2 == NULL )
584     {
585  
586         exception_type = PyExc_UnboundLocalError;
587         Py_INCREF( exception_type );
588         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
589         exception_tb = NULL;
590         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
591         CHAIN_EXCEPTION( exception_value );
592  
593         exception_lineno = 33;
594         type_description = "o";
595         goto frame_exception_exit_1;
596     }
597  
598     frame_c24fecb2b4c7ae2ff72032bfaa9232c9->m_frame.f_lineno = 33;
599     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_2, const_str_plain_compiled_method );
600     if ( tmp_unused == NULL )
601     {
602         assert( ERROR_OCCURRED() );
603  
604         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
605  
606  
607         exception_lineno = 33;
608         type_description = "o";
609         goto frame_exception_exit_1;
610     }
611     Py_DECREF( tmp_unused );
612     tmp_called_instance_3 = var_inst;
613  
614     if ( tmp_called_instance_3 == NULL )
615     {
616  
617         exception_type = PyExc_UnboundLocalError;
618         Py_INCREF( exception_type );
619         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
620         exception_tb = NULL;
621         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
622         CHAIN_EXCEPTION( exception_value );
623  
624         exception_lineno = 34;
625         type_description = "o";
626         goto frame_exception_exit_1;
627     }
628  
629     frame_c24fecb2b4c7ae2ff72032bfaa9232c9->m_frame.f_lineno = 34;
630     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_3, const_str_plain_compiled_method );
631     if ( tmp_unused == NULL )
632     {
633         assert( ERROR_OCCURRED() );
634  
635         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
636  
637  
638         exception_lineno = 34;
639         type_description = "o";
640         goto frame_exception_exit_1;
641     }
642     Py_DECREF( tmp_unused );
643 560
644 #if 0 561 #if 0
645     RESTORE_FRAME_EXCEPTION( frame_c24fecb2b4c7ae2ff72032bfaa9232c9 ); 562     RESTORE_FRAME_EXCEPTION( frame_c24fecb2b4c7ae2ff72032bfaa9232c9 );
646 #endif 563 #endif
647 564
691     // tried codes exits in all cases 608     // tried codes exits in all cases
692     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 609     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
693     return NULL; 610     return NULL;
694     // Return handler code: 611     // Return handler code:
695     try_return_handler_1:; 612     try_return_handler_1:;
n n 613     CHECK_OBJECT( (PyObject *)var_inst );
696     Py_XDECREF( var_inst ); 614     Py_DECREF( var_inst );
697     var_inst = NULL; 615     var_inst = NULL;
698 616
699     goto function_return_exit; 617     goto function_return_exit;
700     // Exception handler code: 618     // Exception handler code:
701     try_except_handler_1:; 619     try_except_handler_1:;
705     exception_keeper_lineno_1 = exception_lineno; 623     exception_keeper_lineno_1 = exception_lineno;
706     exception_type = NULL; 624     exception_type = NULL;
707     exception_value = NULL; 625     exception_value = NULL;
708     exception_tb = NULL; 626     exception_tb = NULL;
709     exception_lineno = -1; 627     exception_lineno = -1;
t 710   t
711     Py_XDECREF( var_inst );
712     var_inst = NULL;
713 628
714     // Re-raise. 629     // Re-raise.
715     exception_type = exception_keeper_type_1; 630     exception_type = exception_keeper_type_1;
716     exception_value = exception_keeper_value_1; 631     exception_value = exception_keeper_value_1;
717     exception_tb = exception_keeper_tb_1; 632     exception_tb = exception_keeper_tb_1;