Construct CallCompiledObjectMethodPosArgsDefaults

Performance Diagrams

Construct CallCompiledObjectMethodPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)22844470388.11538461538461257.0CPython 2.779902021240.03846153846155417.6830078009328Nuitka (master)79902056391.96153846153845417.6829699403987Nuitka (develop)79901034543.8846153846154417.6840754679936Nuitka (factory)Construct CallCompiledObjectMethodPosArgsDefaultsTicks Construct CallCompiledObjectMethodPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)23436063588.11538461538461257.0CPython 3.580301502240.03846153846155419.4435857361783Nuitka (master)80293028391.96153846153845419.45252092177054Nuitka (develop)80305737543.8846153846154419.43912025222943Nuitka (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



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, 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

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
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 import itertools 39 import itertools
40 for x in itertools.repeat(None, 50000): 40 for x in itertools.repeat(None, 50000):
41     calledRepeatedly() 41     calledRepeatedly()
42 42

Context Diff of Generated Code


Construct
Baseline
600     PyObject *exception_keeper_type_1; 600     PyObject *exception_keeper_type_1;
601     PyObject *exception_keeper_value_1; 601     PyObject *exception_keeper_value_1;
602     PyTracebackObject *exception_keeper_tb_1; 602     PyTracebackObject *exception_keeper_tb_1;
603     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 603     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
604     PyObject *tmp_assign_source_1; 604     PyObject *tmp_assign_source_1;
n 605     PyObject *tmp_called_instance_1; n
606     PyObject *tmp_called_instance_2;
607     PyObject *tmp_called_instance_3;
608     PyObject *tmp_called_name_1; 605     PyObject *tmp_called_name_1;
609     PyObject *tmp_return_value; 606     PyObject *tmp_return_value;
n 610     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
611     static struct Nuitka_FrameObject *cache_frame_5804c407dfae0ff130c9b10bc6339a89 = NULL; 607     static struct Nuitka_FrameObject *cache_frame_5804c407dfae0ff130c9b10bc6339a89 = NULL;
612 608
613     struct Nuitka_FrameObject *frame_5804c407dfae0ff130c9b10bc6339a89; 609     struct Nuitka_FrameObject *frame_5804c407dfae0ff130c9b10bc6339a89;
614 610
615     char const *type_description; 611     char const *type_description;
663         goto frame_exception_exit_1; 659         goto frame_exception_exit_1;
664     } 660     }
665     assert( var_inst == NULL ); 661     assert( var_inst == NULL );
666     var_inst = tmp_assign_source_1; 662     var_inst = tmp_assign_source_1;
667 663
n 668     tmp_called_instance_1 = var_inst; n
669  
670     CHECK_OBJECT( tmp_called_instance_1 );
671     frame_5804c407dfae0ff130c9b10bc6339a89->m_frame.f_lineno = 32;
672     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_1, const_str_plain_compiled_method );
673     if ( tmp_unused == NULL )
674     {
675         assert( ERROR_OCCURRED() );
676  
677         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
678  
679  
680         exception_lineno = 32;
681         type_description = "o";
682         goto frame_exception_exit_1;
683     }
684     Py_DECREF( tmp_unused );
685     tmp_called_instance_2 = var_inst;
686  
687     if ( tmp_called_instance_2 == NULL )
688     {
689  
690         exception_type = PyExc_UnboundLocalError;
691         Py_INCREF( exception_type );
692         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
693         exception_tb = NULL;
694         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
695         CHAIN_EXCEPTION( exception_value );
696  
697         exception_lineno = 33;
698         type_description = "o";
699         goto frame_exception_exit_1;
700     }
701  
702     frame_5804c407dfae0ff130c9b10bc6339a89->m_frame.f_lineno = 33;
703     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_2, const_str_plain_compiled_method );
704     if ( tmp_unused == NULL )
705     {
706         assert( ERROR_OCCURRED() );
707  
708         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
709  
710  
711         exception_lineno = 33;
712         type_description = "o";
713         goto frame_exception_exit_1;
714     }
715     Py_DECREF( tmp_unused );
716     tmp_called_instance_3 = var_inst;
717  
718     if ( tmp_called_instance_3 == NULL )
719     {
720  
721         exception_type = PyExc_UnboundLocalError;
722         Py_INCREF( exception_type );
723         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
724         exception_tb = NULL;
725         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
726         CHAIN_EXCEPTION( exception_value );
727  
728         exception_lineno = 34;
729         type_description = "o";
730         goto frame_exception_exit_1;
731     }
732  
733     frame_5804c407dfae0ff130c9b10bc6339a89->m_frame.f_lineno = 34;
734     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_3, const_str_plain_compiled_method );
735     if ( tmp_unused == NULL )
736     {
737         assert( ERROR_OCCURRED() );
738  
739         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
740  
741  
742         exception_lineno = 34;
743         type_description = "o";
744         goto frame_exception_exit_1;
745     }
746     Py_DECREF( tmp_unused );
747 664
748 #if 0 665 #if 0
749     RESTORE_FRAME_EXCEPTION( frame_5804c407dfae0ff130c9b10bc6339a89 ); 666     RESTORE_FRAME_EXCEPTION( frame_5804c407dfae0ff130c9b10bc6339a89 );
750 #endif 667 #endif
751 668
795     // tried codes exits in all cases 712     // tried codes exits in all cases
796     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 713     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
797     return NULL; 714     return NULL;
798     // Return handler code: 715     // Return handler code:
799     try_return_handler_1:; 716     try_return_handler_1:;
n n 717     CHECK_OBJECT( (PyObject *)var_inst );
800     Py_XDECREF( var_inst ); 718     Py_DECREF( var_inst );
801     var_inst = NULL; 719     var_inst = NULL;
802 720
803     goto function_return_exit; 721     goto function_return_exit;
804     // Exception handler code: 722     // Exception handler code:
805     try_except_handler_1:; 723     try_except_handler_1:;
809     exception_keeper_lineno_1 = exception_lineno; 727     exception_keeper_lineno_1 = exception_lineno;
810     exception_type = NULL; 728     exception_type = NULL;
811     exception_value = NULL; 729     exception_value = NULL;
812     exception_tb = NULL; 730     exception_tb = NULL;
813     exception_lineno = 0; 731     exception_lineno = 0;
t 814   t
815     Py_XDECREF( var_inst );
816     var_inst = NULL;
817 732
818     // Re-raise. 733     // Re-raise.
819     exception_type = exception_keeper_type_1; 734     exception_type = exception_keeper_type_1;
820     exception_value = exception_keeper_value_1; 735     exception_value = exception_keeper_value_1;
821     exception_tb = exception_keeper_tb_1; 736     exception_tb = exception_keeper_tb_1;