Construct CallCompiledObjectMethodPosArgsConstant1

Performance Diagrams

Construct CallCompiledObjectMethodPosArgsConstant1 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000140000000140000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)14774100772.9230769230769257.0CPython 2.754251813194.46153846153845413.37241549796875Nuitka (historic)38202655316.0440.2166473903578Nuitka (master)38202360437.53846153846143440.21714081489813Nuitka (develop)38202648559.0769230769231440.2166590987367Nuitka (factory)Construct CallCompiledObjectMethodPosArgsConstant1Ticks Construct CallCompiledObjectMethodPosArgsConstant1 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000140000000140000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)14124162972.9230769230769257.0CPython 3.50194.46153846153845504.11538461538464Nuitka (historic)35000010316.0442.87960735957074Nuitka (master)35021494437.53846153846143442.842019100637Nuitka (develop)35017890559.0769230769231442.8483246342991Nuitka (factory)Construct CallCompiledObjectMethodPosArgsConstant1Ticks

Source Code with Construct

from __future__ import print_function

class C(object):
    def compiled_method(self, a):
        return a

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("some")
    inst.compiled_method("some")
    inst.compiled_method("some")

# 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):
        return a

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("some") n 32  
33     inst.compiled_method("some") 33  
34     inst.compiled_method("some") 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
57 static PyObject *const_str_plain_x; 57 static PyObject *const_str_plain_x;
58 static PyObject *const_str_plain_C; 58 static PyObject *const_str_plain_C;
59 extern PyObject *const_tuple_empty; 59 extern PyObject *const_tuple_empty;
60 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352; 60 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352;
61 static PyObject *const_tuple_str_plain_inst_tuple; 61 static PyObject *const_tuple_str_plain_inst_tuple;
n 62 static PyObject *const_str_plain_some; n
63 extern PyObject *const_str_plain___main__; 62 extern PyObject *const_str_plain___main__;
64 extern PyObject *const_str_plain_type; 63 extern PyObject *const_str_plain_type;
n 65 static PyObject *const_tuple_str_plain_some_tuple; n
66 extern PyObject *const_str_plain___doc__; 64 extern PyObject *const_str_plain___doc__;
67 extern PyObject *const_str_plain___cached__; 65 extern PyObject *const_str_plain___cached__;
68 static PyObject *module_filename_obj; 66 static PyObject *module_filename_obj;
69 67
70 static bool constants_created = false; 68 static bool constants_created = false;
94     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 206 ], 8, 0 ); 92     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 206 ], 8, 0 );
95     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 110 ], 1, 1 ); 93     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 110 ], 1, 1 );
96     const_str_plain_C = UNSTREAM_STRING( &constant_bin[ 35 ], 1, 1 ); 94     const_str_plain_C = UNSTREAM_STRING( &constant_bin[ 35 ], 1, 1 );
97     const_tuple_str_plain_inst_tuple = PyTuple_New( 1 ); 95     const_tuple_str_plain_inst_tuple = PyTuple_New( 1 );
98     PyTuple_SET_ITEM( const_tuple_str_plain_inst_tuple, 0, const_str_plain_inst ); Py_INCREF( const_str_plain_inst ); 96     PyTuple_SET_ITEM( const_tuple_str_plain_inst_tuple, 0, const_str_plain_inst ); Py_INCREF( const_str_plain_inst );
n 99     const_str_plain_some = UNSTREAM_STRING( &constant_bin[ 214 ], 4, 1 ); n
100     const_tuple_str_plain_some_tuple = PyTuple_New( 1 );
101     PyTuple_SET_ITEM( const_tuple_str_plain_some_tuple, 0, const_str_plain_some ); Py_INCREF( const_str_plain_some );
102 97
103     constants_created = true; 98     constants_created = true;
104 } 99 }
105 100
106 #ifndef __NUITKA_NO_ASSERT__ 101 #ifndef __NUITKA_NO_ASSERT__
508     PyObject *exception_keeper_type_1; 503     PyObject *exception_keeper_type_1;
509     PyObject *exception_keeper_value_1; 504     PyObject *exception_keeper_value_1;
510     PyTracebackObject *exception_keeper_tb_1; 505     PyTracebackObject *exception_keeper_tb_1;
511     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 506     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
512     PyObject *tmp_assign_source_1; 507     PyObject *tmp_assign_source_1;
n 513     PyObject *tmp_called_instance_1; n
514     PyObject *tmp_called_instance_2;
515     PyObject *tmp_called_instance_3;
516     PyObject *tmp_called_name_1; 508     PyObject *tmp_called_name_1;
517     PyObject *tmp_return_value; 509     PyObject *tmp_return_value;
n 518     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
519     static struct Nuitka_FrameObject *cache_frame_f8fe0bc61d5c9c4a5bf3e7bc9746dd03 = NULL; 510     static struct Nuitka_FrameObject *cache_frame_f8fe0bc61d5c9c4a5bf3e7bc9746dd03 = NULL;
520 511
521     struct Nuitka_FrameObject *frame_f8fe0bc61d5c9c4a5bf3e7bc9746dd03; 512     struct Nuitka_FrameObject *frame_f8fe0bc61d5c9c4a5bf3e7bc9746dd03;
522 513
523     char const *type_description; 514     char const *type_description;
571         goto frame_exception_exit_1; 562         goto frame_exception_exit_1;
572     } 563     }
573     assert( var_inst == NULL ); 564     assert( var_inst == NULL );
574     var_inst = tmp_assign_source_1; 565     var_inst = tmp_assign_source_1;
575 566
n 576     tmp_called_instance_1 = var_inst; n
577  
578     CHECK_OBJECT( tmp_called_instance_1 );
579     frame_f8fe0bc61d5c9c4a5bf3e7bc9746dd03->m_frame.f_lineno = 32;
580     tmp_unused = CALL_METHOD_WITH_ARGS1( tmp_called_instance_1, const_str_plain_compiled_method, &PyTuple_GET_ITEM( const_tuple_str_plain_some_tuple, 0 ) );
581  
582     if ( tmp_unused == NULL )
583     {
584         assert( ERROR_OCCURRED() );
585  
586         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
587  
588  
589         exception_lineno = 32;
590         type_description = "o";
591         goto frame_exception_exit_1;
592     }
593     Py_DECREF( tmp_unused );
594     tmp_called_instance_2 = var_inst;
595  
596     if ( tmp_called_instance_2 == NULL )
597     {
598  
599         exception_type = PyExc_UnboundLocalError;
600         Py_INCREF( exception_type );
601         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
602         exception_tb = NULL;
603         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
604         CHAIN_EXCEPTION( exception_value );
605  
606         exception_lineno = 33;
607         type_description = "o";
608         goto frame_exception_exit_1;
609     }
610  
611     frame_f8fe0bc61d5c9c4a5bf3e7bc9746dd03->m_frame.f_lineno = 33;
612     tmp_unused = CALL_METHOD_WITH_ARGS1( tmp_called_instance_2, const_str_plain_compiled_method, &PyTuple_GET_ITEM( const_tuple_str_plain_some_tuple, 0 ) );
613  
614     if ( tmp_unused == NULL )
615     {
616         assert( ERROR_OCCURRED() );
617  
618         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
619  
620  
621         exception_lineno = 33;
622         type_description = "o";
623         goto frame_exception_exit_1;
624     }
625     Py_DECREF( tmp_unused );
626     tmp_called_instance_3 = var_inst;
627  
628     if ( tmp_called_instance_3 == NULL )
629     {
630  
631         exception_type = PyExc_UnboundLocalError;
632         Py_INCREF( exception_type );
633         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
634         exception_tb = NULL;
635         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
636         CHAIN_EXCEPTION( exception_value );
637  
638         exception_lineno = 34;
639         type_description = "o";
640         goto frame_exception_exit_1;
641     }
642  
643     frame_f8fe0bc61d5c9c4a5bf3e7bc9746dd03->m_frame.f_lineno = 34;
644     tmp_unused = CALL_METHOD_WITH_ARGS1( tmp_called_instance_3, const_str_plain_compiled_method, &PyTuple_GET_ITEM( const_tuple_str_plain_some_tuple, 0 ) );
645  
646     if ( tmp_unused == NULL )
647     {
648         assert( ERROR_OCCURRED() );
649  
650         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
651  
652  
653         exception_lineno = 34;
654         type_description = "o";
655         goto frame_exception_exit_1;
656     }
657     Py_DECREF( tmp_unused );
658 567
659 #if 0 568 #if 0
660     RESTORE_FRAME_EXCEPTION( frame_f8fe0bc61d5c9c4a5bf3e7bc9746dd03 ); 569     RESTORE_FRAME_EXCEPTION( frame_f8fe0bc61d5c9c4a5bf3e7bc9746dd03 );
661 #endif 570 #endif
662 571
706     // tried codes exits in all cases 615     // tried codes exits in all cases
707     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 616     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
708     return NULL; 617     return NULL;
709     // Return handler code: 618     // Return handler code:
710     try_return_handler_1:; 619     try_return_handler_1:;
n n 620     CHECK_OBJECT( (PyObject *)var_inst );
711     Py_XDECREF( var_inst ); 621     Py_DECREF( var_inst );
712     var_inst = NULL; 622     var_inst = NULL;
713 623
714     goto function_return_exit; 624     goto function_return_exit;
715     // Exception handler code: 625     // Exception handler code:
716     try_except_handler_1:; 626     try_except_handler_1:;
720     exception_keeper_lineno_1 = exception_lineno; 630     exception_keeper_lineno_1 = exception_lineno;
721     exception_type = NULL; 631     exception_type = NULL;
722     exception_value = NULL; 632     exception_value = NULL;
723     exception_tb = NULL; 633     exception_tb = NULL;
724     exception_lineno = -1; 634     exception_lineno = -1;
t 725   t
726     Py_XDECREF( var_inst );
727     var_inst = NULL;
728 635
729     // Re-raise. 636     // Re-raise.
730     exception_type = exception_keeper_type_1; 637     exception_type = exception_keeper_type_1;
731     exception_value = exception_keeper_value_1; 638     exception_value = exception_keeper_value_1;
732     exception_tb = exception_keeper_tb_1; 639     exception_tb = exception_keeper_tb_1;