Construct CallCompiledObjectMethodPosArgsConstant1

Performance Diagrams

Construct CallCompiledObjectMethodPosArgsConstant1 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000140000000140000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)14774100772.9230769230769257.0CPython 2.754251813194.46153846153845413.37241549796875Nuitka (historic)38253250316.0440.1320209001335Nuitka (master)38253424437.53846153846143440.131729863286Nuitka (develop)38203294559.0769230769231440.21557858262474Nuitka (factory)Construct CallCompiledObjectMethodPosArgsConstant1Ticks Construct CallCompiledObjectMethodPosArgsConstant1 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000140000000140000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)14124162972.9230769230769257.0CPython 3.50194.46153846153845504.11538461538464Nuitka (historic)36301013316.0440.60338144085966Nuitka (master)36305594437.53846153846143440.5953665547037Nuitka (develop)35000178559.0769230769231442.8793134279239Nuitka (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___loader__; 62 extern PyObject *const_str_plain___loader__;
64 extern PyObject *const_str_plain___main__; 63 extern PyObject *const_str_plain___main__;
65 extern PyObject *const_str_plain_type; 64 extern PyObject *const_str_plain_type;
n 66 static PyObject *const_tuple_str_plain_some_tuple; n
67 extern PyObject *const_str_plain___doc__; 65 extern PyObject *const_str_plain___doc__;
68 extern PyObject *const_str_plain___cached__; 66 extern PyObject *const_str_plain___cached__;
69 static PyObject *module_filename_obj; 67 static PyObject *module_filename_obj;
70 68
71 static bool constants_created = false; 69 static bool constants_created = false;
95     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 206 ], 8, 0 ); 93     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 206 ], 8, 0 );
96     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 25 ], 1, 1 ); 94     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 25 ], 1, 1 );
97     const_str_plain_C = UNSTREAM_STRING( &constant_bin[ 55 ], 1, 1 ); 95     const_str_plain_C = UNSTREAM_STRING( &constant_bin[ 55 ], 1, 1 );
98     const_tuple_str_plain_inst_tuple = PyTuple_New( 1 ); 96     const_tuple_str_plain_inst_tuple = PyTuple_New( 1 );
99     PyTuple_SET_ITEM( const_tuple_str_plain_inst_tuple, 0, const_str_plain_inst ); Py_INCREF( const_str_plain_inst ); 97     PyTuple_SET_ITEM( const_tuple_str_plain_inst_tuple, 0, const_str_plain_inst ); Py_INCREF( const_str_plain_inst );
n 100     const_str_plain_some = UNSTREAM_STRING( &constant_bin[ 214 ], 4, 1 ); n
101     const_tuple_str_plain_some_tuple = PyTuple_New( 1 );
102     PyTuple_SET_ITEM( const_tuple_str_plain_some_tuple, 0, const_str_plain_some ); Py_INCREF( const_str_plain_some );
103 98
104     constants_created = true; 99     constants_created = true;
105 } 100 }
106 101
107 #ifndef __NUITKA_NO_ASSERT__ 102 #ifndef __NUITKA_NO_ASSERT__
401     PyObject *exception_keeper_type_1; 396     PyObject *exception_keeper_type_1;
402     PyObject *exception_keeper_value_1; 397     PyObject *exception_keeper_value_1;
403     PyTracebackObject *exception_keeper_tb_1; 398     PyTracebackObject *exception_keeper_tb_1;
404     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 399     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
405     PyObject *tmp_assign_source_1; 400     PyObject *tmp_assign_source_1;
n 406     PyObject *tmp_called_instance_1; n
407     PyObject *tmp_called_instance_2;
408     PyObject *tmp_called_instance_3;
409     PyObject *tmp_called_name_1; 401     PyObject *tmp_called_name_1;
410     PyObject *tmp_return_value; 402     PyObject *tmp_return_value;
n 411     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
412     static struct Nuitka_FrameObject *cache_frame_function = NULL; 403     static struct Nuitka_FrameObject *cache_frame_function = NULL;
413 404
414     struct Nuitka_FrameObject *frame_function; 405     struct Nuitka_FrameObject *frame_function;
415 406
416     char const *type_description; 407     char const *type_description;
464         goto frame_exception_exit_1; 455         goto frame_exception_exit_1;
465     } 456     }
466     assert( var_inst == NULL ); 457     assert( var_inst == NULL );
467     var_inst = tmp_assign_source_1; 458     var_inst = tmp_assign_source_1;
468 459
n 469     tmp_called_instance_1 = var_inst; n
470  
471     frame_function->m_frame.f_lineno = 32;
472     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 ) );
473  
474     if ( tmp_unused == NULL )
475     {
476         assert( ERROR_OCCURRED() );
477  
478         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
479  
480  
481         exception_lineno = 32;
482         type_description = "o";
483         goto frame_exception_exit_1;
484     }
485     Py_DECREF( tmp_unused );
486     tmp_called_instance_2 = var_inst;
487  
488     if ( tmp_called_instance_2 == NULL )
489     {
490  
491         exception_type = PyExc_UnboundLocalError;
492         Py_INCREF( exception_type );
493         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
494         exception_tb = NULL;
495         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
496         CHAIN_EXCEPTION( exception_value );
497  
498         exception_lineno = 33;
499         type_description = "o";
500         goto frame_exception_exit_1;
501     }
502  
503     frame_function->m_frame.f_lineno = 33;
504     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 ) );
505  
506     if ( tmp_unused == NULL )
507     {
508         assert( ERROR_OCCURRED() );
509  
510         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
511  
512  
513         exception_lineno = 33;
514         type_description = "o";
515         goto frame_exception_exit_1;
516     }
517     Py_DECREF( tmp_unused );
518     tmp_called_instance_3 = var_inst;
519  
520     if ( tmp_called_instance_3 == NULL )
521     {
522  
523         exception_type = PyExc_UnboundLocalError;
524         Py_INCREF( exception_type );
525         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
526         exception_tb = NULL;
527         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
528         CHAIN_EXCEPTION( exception_value );
529  
530         exception_lineno = 34;
531         type_description = "o";
532         goto frame_exception_exit_1;
533     }
534  
535     frame_function->m_frame.f_lineno = 34;
536     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 ) );
537  
538     if ( tmp_unused == NULL )
539     {
540         assert( ERROR_OCCURRED() );
541  
542         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
543  
544  
545         exception_lineno = 34;
546         type_description = "o";
547         goto frame_exception_exit_1;
548     }
549     Py_DECREF( tmp_unused );
550 460
551 #if 0 461 #if 0
552     RESTORE_FRAME_EXCEPTION( frame_function ); 462     RESTORE_FRAME_EXCEPTION( frame_function );
553 #endif 463 #endif
554 464
598     // tried codes exits in all cases 508     // tried codes exits in all cases
599     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 509     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
600     return NULL; 510     return NULL;
601     // Return handler code: 511     // Return handler code:
602     try_return_handler_1:; 512     try_return_handler_1:;
n n 513     CHECK_OBJECT( (PyObject *)var_inst );
603     Py_XDECREF( var_inst ); 514     Py_DECREF( var_inst );
604     var_inst = NULL; 515     var_inst = NULL;
605 516
606     goto function_return_exit; 517     goto function_return_exit;
607     // Exception handler code: 518     // Exception handler code:
608     try_except_handler_1:; 519     try_except_handler_1:;
612     exception_keeper_lineno_1 = exception_lineno; 523     exception_keeper_lineno_1 = exception_lineno;
613     exception_type = NULL; 524     exception_type = NULL;
614     exception_value = NULL; 525     exception_value = NULL;
615     exception_tb = NULL; 526     exception_tb = NULL;
616     exception_lineno = -1; 527     exception_lineno = -1;
t 617   t
618     Py_XDECREF( var_inst );
619     var_inst = NULL;
620 528
621     // Re-raise. 529     // Re-raise.
622     exception_type = exception_keeper_type_1; 530     exception_type = exception_keeper_type_1;
623     exception_value = exception_keeper_value_1; 531     exception_value = exception_keeper_value_1;
624     exception_tb = exception_keeper_tb_1; 532     exception_tb = exception_keeper_tb_1;