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)79952355437.53846153846143417.62893709977277Nuitka (develop)79952651559.0769230769231417.62861690922347Nuitka (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)80393900437.53846153846143419.34717982127813Nuitka (develop)80395741559.0769230769231419.3452386508034Nuitka (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
483     PyObject *exception_keeper_type_1; 483     PyObject *exception_keeper_type_1;
484     PyObject *exception_keeper_value_1; 484     PyObject *exception_keeper_value_1;
485     PyTracebackObject *exception_keeper_tb_1; 485     PyTracebackObject *exception_keeper_tb_1;
486     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 486     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
487     PyObject *tmp_assign_source_1; 487     PyObject *tmp_assign_source_1;
n 488     PyObject *tmp_called_instance_1; n
489     PyObject *tmp_called_instance_2;
490     PyObject *tmp_called_instance_3;
491     PyObject *tmp_called_name_1; 488     PyObject *tmp_called_name_1;
492     PyObject *tmp_frame_locals; 489     PyObject *tmp_frame_locals;
493     PyObject *tmp_return_value; 490     PyObject *tmp_return_value;
n 494     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
495     static PyFrameObject *cache_frame_function = NULL; 491     static PyFrameObject *cache_frame_function = NULL;
496 492
497     PyFrameObject *frame_function; 493     PyFrameObject *frame_function;
498 494
499     tmp_return_value = NULL; 495     tmp_return_value = NULL;
549         goto frame_exception_exit_1; 545         goto frame_exception_exit_1;
550     } 546     }
551     assert( var_inst == NULL ); 547     assert( var_inst == NULL );
552     var_inst = tmp_assign_source_1; 548     var_inst = tmp_assign_source_1;
553 549
n 554     tmp_called_instance_1 = var_inst; n
555  
556     frame_function->f_lineno = 32;
557     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_1, const_str_plain_compiled_method );
558     if ( tmp_unused == NULL )
559     {
560         assert( ERROR_OCCURRED() );
561  
562         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
563  
564  
565         exception_lineno = 32;
566         goto frame_exception_exit_1;
567     }
568     Py_DECREF( tmp_unused );
569     tmp_called_instance_2 = var_inst;
570  
571     if ( tmp_called_instance_2 == NULL )
572     {
573  
574         exception_type = PyExc_UnboundLocalError;
575         Py_INCREF( exception_type );
576         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
577         exception_tb = NULL;
578         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
579         CHAIN_EXCEPTION( exception_value );
580  
581         exception_lineno = 33;
582         goto frame_exception_exit_1;
583     }
584  
585     frame_function->f_lineno = 33;
586     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_2, const_str_plain_compiled_method );
587     if ( tmp_unused == NULL )
588     {
589         assert( ERROR_OCCURRED() );
590  
591         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
592  
593  
594         exception_lineno = 33;
595         goto frame_exception_exit_1;
596     }
597     Py_DECREF( tmp_unused );
598     tmp_called_instance_3 = var_inst;
599  
600     if ( tmp_called_instance_3 == NULL )
601     {
602  
603         exception_type = PyExc_UnboundLocalError;
604         Py_INCREF( exception_type );
605         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
606         exception_tb = NULL;
607         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
608         CHAIN_EXCEPTION( exception_value );
609  
610         exception_lineno = 34;
611         goto frame_exception_exit_1;
612     }
613  
614     frame_function->f_lineno = 34;
615     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_3, const_str_plain_compiled_method );
616     if ( tmp_unused == NULL )
617     {
618         assert( ERROR_OCCURRED() );
619  
620         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
621  
622  
623         exception_lineno = 34;
624         goto frame_exception_exit_1;
625     }
626     Py_DECREF( tmp_unused );
627 550
628 #if 0 551 #if 0
629     RESTORE_FRAME_EXCEPTION( frame_function ); 552     RESTORE_FRAME_EXCEPTION( frame_function );
630 #endif 553 #endif
631     // Put the previous frame back on top. 554     // Put the previous frame back on top.
697     // tried codes exits in all cases 620     // tried codes exits in all cases
698     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 621     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
699     return NULL; 622     return NULL;
700     // Return handler code: 623     // Return handler code:
701     try_return_handler_1:; 624     try_return_handler_1:;
n n 625     CHECK_OBJECT( (PyObject *)var_inst );
702     Py_XDECREF( var_inst ); 626     Py_DECREF( var_inst );
703     var_inst = NULL; 627     var_inst = NULL;
704 628
705     goto function_return_exit; 629     goto function_return_exit;
706     // Exception handler code: 630     // Exception handler code:
707     try_except_handler_1:; 631     try_except_handler_1:;
711     exception_keeper_lineno_1 = exception_lineno; 635     exception_keeper_lineno_1 = exception_lineno;
712     exception_type = NULL; 636     exception_type = NULL;
713     exception_value = NULL; 637     exception_value = NULL;
714     exception_tb = NULL; 638     exception_tb = NULL;
715     exception_lineno = -1; 639     exception_lineno = -1;
t 716   t
717     Py_XDECREF( var_inst );
718     var_inst = NULL;
719 640
720     // Re-raise. 641     // Re-raise.
721     exception_type = exception_keeper_type_1; 642     exception_type = exception_keeper_type_1;
722     exception_value = exception_keeper_value_1; 643     exception_value = exception_keeper_value_1;
723     exception_tb = exception_keeper_tb_1; 644     exception_tb = exception_keeper_tb_1;