Construct CallCompiledObjectMethodPosArgsDefaults

Performance Diagrams

Construct CallCompiledObjectMethodPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)22844569972.9230769230769257.0CPython 2.7116750303194.46153846153845377.8236831033868Nuitka (historic)79902663316.0417.6826901699599Nuitka (master)79901511437.53846153846143417.68393631696256Nuitka (develop)79901613559.0769230769231417.68382598103005Nuitka (factory)Construct CallCompiledObjectMethodPosArgsDefaultsTicks Construct CallCompiledObjectMethodPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)23436345772.9230769230769257.0CPython 3.50194.46153846153845504.11538461538464Nuitka (historic)80307387316.0419.4384000718363Nuitka (master)80302743437.53846153846143419.4432967560756Nuitka (develop)80298951559.0769230769231419.4472950822245Nuitka (factory)Construct CallCompiledObjectMethodPosArgsDefaultsTicks

Source Code with Construct

from __future__ import print_function

class C(object):
    def compiled_method(self, a = 1, b = 2,c = 3,d = 4,e = 5,f = 6):
        return a, b, c, d, e, f

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, a = 1, b = 2,c = 3,d = 4,e = 5,f = 6):
        return a, b, c, d, e, f

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
33     inst.compiled_method()
34     inst.compiled_method()
35 # construct_alternative
36 32
37 33
t t 34  
35 # construct_alternative
36     pass
37 # construct_end
38 38
39 for x in xrange(50000): 39 for x in xrange(50000):
40     calledRepeatedly() 40     calledRepeatedly()
41 41
42 print("OK.") 42 print("OK.")

Context Diff of Generated Code


Construct
Baseline
587     PyObject *exception_keeper_type_1; 587     PyObject *exception_keeper_type_1;
588     PyObject *exception_keeper_value_1; 588     PyObject *exception_keeper_value_1;
589     PyTracebackObject *exception_keeper_tb_1; 589     PyTracebackObject *exception_keeper_tb_1;
590     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 590     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
591     PyObject *tmp_assign_source_1; 591     PyObject *tmp_assign_source_1;
n 592     PyObject *tmp_called_instance_1; n
593     PyObject *tmp_called_instance_2;
594     PyObject *tmp_called_instance_3;
595     PyObject *tmp_called_name_1; 592     PyObject *tmp_called_name_1;
596     PyObject *tmp_return_value; 593     PyObject *tmp_return_value;
n 597     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
598     static struct Nuitka_FrameObject *cache_frame_8aa792e8ca15019891df39e0a906366e = NULL; 594     static struct Nuitka_FrameObject *cache_frame_8aa792e8ca15019891df39e0a906366e = NULL;
599 595
600     struct Nuitka_FrameObject *frame_8aa792e8ca15019891df39e0a906366e; 596     struct Nuitka_FrameObject *frame_8aa792e8ca15019891df39e0a906366e;
601 597
602     char const *type_description; 598     char const *type_description;
650         goto frame_exception_exit_1; 646         goto frame_exception_exit_1;
651     } 647     }
652     assert( var_inst == NULL ); 648     assert( var_inst == NULL );
653     var_inst = tmp_assign_source_1; 649     var_inst = tmp_assign_source_1;
654 650
n 655     tmp_called_instance_1 = var_inst; n
656  
657     CHECK_OBJECT( tmp_called_instance_1 );
658     frame_8aa792e8ca15019891df39e0a906366e->m_frame.f_lineno = 32;
659     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_1, const_str_plain_compiled_method );
660     if ( tmp_unused == NULL )
661     {
662         assert( ERROR_OCCURRED() );
663  
664         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
665  
666  
667         exception_lineno = 32;
668         type_description = "o";
669         goto frame_exception_exit_1;
670     }
671     Py_DECREF( tmp_unused );
672     tmp_called_instance_2 = var_inst;
673  
674     if ( tmp_called_instance_2 == NULL )
675     {
676  
677         exception_type = PyExc_UnboundLocalError;
678         Py_INCREF( exception_type );
679         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
680         exception_tb = NULL;
681         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
682         CHAIN_EXCEPTION( exception_value );
683  
684         exception_lineno = 33;
685         type_description = "o";
686         goto frame_exception_exit_1;
687     }
688  
689     frame_8aa792e8ca15019891df39e0a906366e->m_frame.f_lineno = 33;
690     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_2, const_str_plain_compiled_method );
691     if ( tmp_unused == NULL )
692     {
693         assert( ERROR_OCCURRED() );
694  
695         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
696  
697  
698         exception_lineno = 33;
699         type_description = "o";
700         goto frame_exception_exit_1;
701     }
702     Py_DECREF( tmp_unused );
703     tmp_called_instance_3 = var_inst;
704  
705     if ( tmp_called_instance_3 == NULL )
706     {
707  
708         exception_type = PyExc_UnboundLocalError;
709         Py_INCREF( exception_type );
710         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
711         exception_tb = NULL;
712         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
713         CHAIN_EXCEPTION( exception_value );
714  
715         exception_lineno = 34;
716         type_description = "o";
717         goto frame_exception_exit_1;
718     }
719  
720     frame_8aa792e8ca15019891df39e0a906366e->m_frame.f_lineno = 34;
721     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_3, const_str_plain_compiled_method );
722     if ( tmp_unused == NULL )
723     {
724         assert( ERROR_OCCURRED() );
725  
726         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
727  
728  
729         exception_lineno = 34;
730         type_description = "o";
731         goto frame_exception_exit_1;
732     }
733     Py_DECREF( tmp_unused );
734 651
735 #if 0 652 #if 0
736     RESTORE_FRAME_EXCEPTION( frame_8aa792e8ca15019891df39e0a906366e ); 653     RESTORE_FRAME_EXCEPTION( frame_8aa792e8ca15019891df39e0a906366e );
737 #endif 654 #endif
738 655
782     // tried codes exits in all cases 699     // tried codes exits in all cases
783     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 700     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
784     return NULL; 701     return NULL;
785     // Return handler code: 702     // Return handler code:
786     try_return_handler_1:; 703     try_return_handler_1:;
n n 704     CHECK_OBJECT( (PyObject *)var_inst );
787     Py_XDECREF( var_inst ); 705     Py_DECREF( var_inst );
788     var_inst = NULL; 706     var_inst = NULL;
789 707
790     goto function_return_exit; 708     goto function_return_exit;
791     // Exception handler code: 709     // Exception handler code:
792     try_except_handler_1:; 710     try_except_handler_1:;
796     exception_keeper_lineno_1 = exception_lineno; 714     exception_keeper_lineno_1 = exception_lineno;
797     exception_type = NULL; 715     exception_type = NULL;
798     exception_value = NULL; 716     exception_value = NULL;
799     exception_tb = NULL; 717     exception_tb = NULL;
800     exception_lineno = -1; 718     exception_lineno = -1;
t 801   t
802     Py_XDECREF( var_inst );
803     var_inst = NULL;
804 719
805     // Re-raise. 720     // Re-raise.
806     exception_type = exception_keeper_type_1; 721     exception_type = exception_keeper_type_1;
807     exception_value = exception_keeper_value_1; 722     exception_value = exception_keeper_value_1;
808     exception_tb = exception_keeper_tb_1; 723     exception_tb = exception_keeper_tb_1;