Construct CallCompiledObjectMethodPosArgsDefaults

Performance Diagrams

Construct CallCompiledObjectMethodPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)22844569972.9230769230769257.0CPython 2.7116750303194.46153846153845377.8236831033868Nuitka (historic)79952633316.0417.62863638027034Nuitka (master)79952621437.53846153846143417.6286493609683Nuitka (develop)79902633559.0769230769231417.6827226217048Nuitka (factory)Construct CallCompiledObjectMethodPosArgsDefaultsTicks Construct CallCompiledObjectMethodPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)23436345772.9230769230769257.0CPython 3.50194.46153846153845504.11538461538464Nuitka (historic)80407800316.0419.33252350970923Nuitka (master)80402565437.53846153846143419.33804335079293Nuitka (develop)80295365559.0769230769231419.4510761997271Nuitka (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
474     PyObject *exception_keeper_type_1; 474     PyObject *exception_keeper_type_1;
475     PyObject *exception_keeper_value_1; 475     PyObject *exception_keeper_value_1;
476     PyTracebackObject *exception_keeper_tb_1; 476     PyTracebackObject *exception_keeper_tb_1;
477     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 477     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
478     PyObject *tmp_assign_source_1; 478     PyObject *tmp_assign_source_1;
n 479     PyObject *tmp_called_instance_1; n
480     PyObject *tmp_called_instance_2;
481     PyObject *tmp_called_instance_3;
482     PyObject *tmp_called_name_1; 479     PyObject *tmp_called_name_1;
483     PyObject *tmp_return_value; 480     PyObject *tmp_return_value;
n 484     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
485     static struct Nuitka_FrameObject *cache_frame_function = NULL; 481     static struct Nuitka_FrameObject *cache_frame_function = NULL;
486 482
487     struct Nuitka_FrameObject *frame_function; 483     struct Nuitka_FrameObject *frame_function;
488 484
489     char const *type_description; 485     char const *type_description;
537         goto frame_exception_exit_1; 533         goto frame_exception_exit_1;
538     } 534     }
539     assert( var_inst == NULL ); 535     assert( var_inst == NULL );
540     var_inst = tmp_assign_source_1; 536     var_inst = tmp_assign_source_1;
541 537
n 542     tmp_called_instance_1 = var_inst; n
543  
544     frame_function->m_frame.f_lineno = 32;
545     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_1, const_str_plain_compiled_method );
546     if ( tmp_unused == NULL )
547     {
548         assert( ERROR_OCCURRED() );
549  
550         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
551  
552  
553         exception_lineno = 32;
554         type_description = "o";
555         goto frame_exception_exit_1;
556     }
557     Py_DECREF( tmp_unused );
558     tmp_called_instance_2 = var_inst;
559  
560     if ( tmp_called_instance_2 == NULL )
561     {
562  
563         exception_type = PyExc_UnboundLocalError;
564         Py_INCREF( exception_type );
565         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
566         exception_tb = NULL;
567         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
568         CHAIN_EXCEPTION( exception_value );
569  
570         exception_lineno = 33;
571         type_description = "o";
572         goto frame_exception_exit_1;
573     }
574  
575     frame_function->m_frame.f_lineno = 33;
576     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_2, const_str_plain_compiled_method );
577     if ( tmp_unused == NULL )
578     {
579         assert( ERROR_OCCURRED() );
580  
581         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
582  
583  
584         exception_lineno = 33;
585         type_description = "o";
586         goto frame_exception_exit_1;
587     }
588     Py_DECREF( tmp_unused );
589     tmp_called_instance_3 = var_inst;
590  
591     if ( tmp_called_instance_3 == NULL )
592     {
593  
594         exception_type = PyExc_UnboundLocalError;
595         Py_INCREF( exception_type );
596         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
597         exception_tb = NULL;
598         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
599         CHAIN_EXCEPTION( exception_value );
600  
601         exception_lineno = 34;
602         type_description = "o";
603         goto frame_exception_exit_1;
604     }
605  
606     frame_function->m_frame.f_lineno = 34;
607     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_3, const_str_plain_compiled_method );
608     if ( tmp_unused == NULL )
609     {
610         assert( ERROR_OCCURRED() );
611  
612         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
613  
614  
615         exception_lineno = 34;
616         type_description = "o";
617         goto frame_exception_exit_1;
618     }
619     Py_DECREF( tmp_unused );
620 538
621 #if 0 539 #if 0
622     RESTORE_FRAME_EXCEPTION( frame_function ); 540     RESTORE_FRAME_EXCEPTION( frame_function );
623 #endif 541 #endif
624 542
668     // tried codes exits in all cases 586     // tried codes exits in all cases
669     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 587     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
670     return NULL; 588     return NULL;
671     // Return handler code: 589     // Return handler code:
672     try_return_handler_1:; 590     try_return_handler_1:;
n n 591     CHECK_OBJECT( (PyObject *)var_inst );
673     Py_XDECREF( var_inst ); 592     Py_DECREF( var_inst );
674     var_inst = NULL; 593     var_inst = NULL;
675 594
676     goto function_return_exit; 595     goto function_return_exit;
677     // Exception handler code: 596     // Exception handler code:
678     try_except_handler_1:; 597     try_except_handler_1:;
682     exception_keeper_lineno_1 = exception_lineno; 601     exception_keeper_lineno_1 = exception_lineno;
683     exception_type = NULL; 602     exception_type = NULL;
684     exception_value = NULL; 603     exception_value = NULL;
685     exception_tb = NULL; 604     exception_tb = NULL;
686     exception_lineno = -1; 605     exception_lineno = -1;
t 687   t
688     Py_XDECREF( var_inst );
689     var_inst = NULL;
690 606
691     // Re-raise. 607     // Re-raise.
692     exception_type = exception_keeper_type_1; 608     exception_type = exception_keeper_type_1;
693     exception_value = exception_keeper_value_1; 609     exception_value = exception_keeper_value_1;
694     exception_tb = exception_keeper_tb_1; 610     exception_tb = exception_keeper_tb_1;