Construct CallCompiledObjectMethodPosArgsConstant1

Performance Diagrams

Construct CallCompiledObjectMethodPosArgsConstant1 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000140000000140000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)14774152988.11538461538461257.0CPython 2.738201492240.03846153846155440.2188184138697Nuitka (master)38201586391.96153846153845440.21866118762256Nuitka (develop)38201586543.8846153846154440.21866118762256Nuitka (factory)Construct CallCompiledObjectMethodPosArgsConstant1Ticks Construct CallCompiledObjectMethodPosArgsConstant1 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000140000000140000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)14124554088.11538461538461257.0CPython 3.536200894240.03846153846155440.7803027131117Nuitka (master)36195059391.96153846153845440.7905113063829Nuitka (develop)36200467543.8846153846154440.7810497686947Nuitka (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



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):
        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

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

Context Diff of Generated Code


Construct
Baseline
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;
62 static PyObject *const_str_plain_repeat; 62 static PyObject *const_str_plain_repeat;
n 63 static PyObject *const_str_plain_some; n
64 static PyObject *const_tuple_none_int_pos_50000_tuple; 63 static PyObject *const_tuple_none_int_pos_50000_tuple;
65 extern PyObject *const_str_plain___loader__; 64 extern PyObject *const_str_plain___loader__;
66 extern PyObject *const_str_plain___main__; 65 extern PyObject *const_str_plain___main__;
n 67 static PyObject *const_tuple_str_plain_some_tuple; n
68 extern PyObject *const_str_plain___doc__; 66 extern PyObject *const_str_plain___doc__;
69 extern PyObject *const_str_plain___cached__; 67 extern PyObject *const_str_plain___cached__;
70 static PyObject *const_str_plain_print_function; 68 static PyObject *const_str_plain_print_function;
71 static PyObject *module_filename_obj; 69 static PyObject *module_filename_obj;
72 70
100     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 25 ], 1, 1 ); 98     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 25 ], 1, 1 );
101     const_str_plain_C = UNSTREAM_STRING( &constant_bin[ 55 ], 1, 1 ); 99     const_str_plain_C = UNSTREAM_STRING( &constant_bin[ 55 ], 1, 1 );
102     const_tuple_str_plain_inst_tuple = PyTuple_New( 1 ); 100     const_tuple_str_plain_inst_tuple = PyTuple_New( 1 );
103     PyTuple_SET_ITEM( const_tuple_str_plain_inst_tuple, 0, const_str_plain_inst ); Py_INCREF( const_str_plain_inst ); 101     PyTuple_SET_ITEM( const_tuple_str_plain_inst_tuple, 0, const_str_plain_inst ); Py_INCREF( const_str_plain_inst );
104     const_str_plain_repeat = UNSTREAM_STRING( &constant_bin[ 225 ], 6, 1 ); 102     const_str_plain_repeat = UNSTREAM_STRING( &constant_bin[ 225 ], 6, 1 );
n 105     const_str_plain_some = UNSTREAM_STRING( &constant_bin[ 231 ], 4, 1 ); n
106     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 ); 103     const_tuple_none_int_pos_50000_tuple = PyTuple_New( 2 );
107     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None ); 104     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 0, Py_None ); Py_INCREF( Py_None );
108     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 ); 105     PyTuple_SET_ITEM( const_tuple_none_int_pos_50000_tuple, 1, const_int_pos_50000 ); Py_INCREF( const_int_pos_50000 );
n 109     const_tuple_str_plain_some_tuple = PyTuple_New( 1 ); n
110     PyTuple_SET_ITEM( const_tuple_str_plain_some_tuple, 0, const_str_plain_some ); Py_INCREF( const_str_plain_some );
111     const_str_plain_print_function = UNSTREAM_STRING( &constant_bin[ 235 ], 14, 1 ); 106     const_str_plain_print_function = UNSTREAM_STRING( &constant_bin[ 231 ], 14, 1 );
112 107
113     constants_created = true; 108     constants_created = true;
114 } 109 }
115 110
116 #ifndef __NUITKA_NO_ASSERT__ 111 #ifndef __NUITKA_NO_ASSERT__
520     PyObject *exception_keeper_type_1; 515     PyObject *exception_keeper_type_1;
521     PyObject *exception_keeper_value_1; 516     PyObject *exception_keeper_value_1;
522     PyTracebackObject *exception_keeper_tb_1; 517     PyTracebackObject *exception_keeper_tb_1;
523     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 518     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
524     PyObject *tmp_assign_source_1; 519     PyObject *tmp_assign_source_1;
n 525     PyObject *tmp_called_instance_1; n
526     PyObject *tmp_called_instance_2;
527     PyObject *tmp_called_instance_3;
528     PyObject *tmp_called_name_1; 520     PyObject *tmp_called_name_1;
529     PyObject *tmp_return_value; 521     PyObject *tmp_return_value;
n 530     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
531     static struct Nuitka_FrameObject *cache_frame_6f4a9a36564676ffbb1e0755fbb01e6f = NULL; 522     static struct Nuitka_FrameObject *cache_frame_6f4a9a36564676ffbb1e0755fbb01e6f = NULL;
532 523
533     struct Nuitka_FrameObject *frame_6f4a9a36564676ffbb1e0755fbb01e6f; 524     struct Nuitka_FrameObject *frame_6f4a9a36564676ffbb1e0755fbb01e6f;
534 525
535     char const *type_description; 526     char const *type_description;
583         goto frame_exception_exit_1; 574         goto frame_exception_exit_1;
584     } 575     }
585     assert( var_inst == NULL ); 576     assert( var_inst == NULL );
586     var_inst = tmp_assign_source_1; 577     var_inst = tmp_assign_source_1;
587 578
n 588     tmp_called_instance_1 = var_inst; n
589  
590     CHECK_OBJECT( tmp_called_instance_1 );
591     frame_6f4a9a36564676ffbb1e0755fbb01e6f->m_frame.f_lineno = 32;
592     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 ) );
593  
594     if ( tmp_unused == NULL )
595     {
596         assert( ERROR_OCCURRED() );
597  
598         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
599  
600  
601         exception_lineno = 32;
602         type_description = "o";
603         goto frame_exception_exit_1;
604     }
605     Py_DECREF( tmp_unused );
606     tmp_called_instance_2 = var_inst;
607  
608     if ( tmp_called_instance_2 == NULL )
609     {
610  
611         exception_type = PyExc_UnboundLocalError;
612         Py_INCREF( exception_type );
613         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
614         exception_tb = NULL;
615         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
616         CHAIN_EXCEPTION( exception_value );
617  
618         exception_lineno = 33;
619         type_description = "o";
620         goto frame_exception_exit_1;
621     }
622  
623     frame_6f4a9a36564676ffbb1e0755fbb01e6f->m_frame.f_lineno = 33;
624     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 ) );
625  
626     if ( tmp_unused == NULL )
627     {
628         assert( ERROR_OCCURRED() );
629  
630         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
631  
632  
633         exception_lineno = 33;
634         type_description = "o";
635         goto frame_exception_exit_1;
636     }
637     Py_DECREF( tmp_unused );
638     tmp_called_instance_3 = var_inst;
639  
640     if ( tmp_called_instance_3 == NULL )
641     {
642  
643         exception_type = PyExc_UnboundLocalError;
644         Py_INCREF( exception_type );
645         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
646         exception_tb = NULL;
647         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
648         CHAIN_EXCEPTION( exception_value );
649  
650         exception_lineno = 34;
651         type_description = "o";
652         goto frame_exception_exit_1;
653     }
654  
655     frame_6f4a9a36564676ffbb1e0755fbb01e6f->m_frame.f_lineno = 34;
656     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 ) );
657  
658     if ( tmp_unused == NULL )
659     {
660         assert( ERROR_OCCURRED() );
661  
662         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
663  
664  
665         exception_lineno = 34;
666         type_description = "o";
667         goto frame_exception_exit_1;
668     }
669     Py_DECREF( tmp_unused );
670 579
671 #if 0 580 #if 0
672     RESTORE_FRAME_EXCEPTION( frame_6f4a9a36564676ffbb1e0755fbb01e6f ); 581     RESTORE_FRAME_EXCEPTION( frame_6f4a9a36564676ffbb1e0755fbb01e6f );
673 #endif 582 #endif
674 583
718     // tried codes exits in all cases 627     // tried codes exits in all cases
719     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 628     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
720     return NULL; 629     return NULL;
721     // Return handler code: 630     // Return handler code:
722     try_return_handler_1:; 631     try_return_handler_1:;
n n 632     CHECK_OBJECT( (PyObject *)var_inst );
723     Py_XDECREF( var_inst ); 633     Py_DECREF( var_inst );
724     var_inst = NULL; 634     var_inst = NULL;
725 635
726     goto function_return_exit; 636     goto function_return_exit;
727     // Exception handler code: 637     // Exception handler code:
728     try_except_handler_1:; 638     try_except_handler_1:;
732     exception_keeper_lineno_1 = exception_lineno; 642     exception_keeper_lineno_1 = exception_lineno;
733     exception_type = NULL; 643     exception_type = NULL;
734     exception_value = NULL; 644     exception_value = NULL;
735     exception_tb = NULL; 645     exception_tb = NULL;
736     exception_lineno = 0; 646     exception_lineno = 0;
t 737   t
738     Py_XDECREF( var_inst );
739     var_inst = NULL;
740 647
741     // Re-raise. 648     // Re-raise.
742     exception_type = exception_keeper_type_1; 649     exception_type = exception_keeper_type_1;
743     exception_value = exception_keeper_value_1; 650     exception_value = exception_keeper_value_1;
744     exception_tb = exception_keeper_tb_1; 651     exception_tb = exception_keeper_tb_1;