Construct CallCompiledObjectMethodNoArgs

Performance Diagrams

Construct CallCompiledObjectMethodNoArgs 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)13812050072.9230769230769257.0CPython 2.752150341194.46153846153845410.8116999774166Nuitka (historic)28653389316.0452.8507769483893Nuitka (master)28652331437.53846153846143452.85266984681436Nuitka (develop)28602300559.0769230769231452.94218175712234Nuitka (factory)Construct CallCompiledObjectMethodNoArgsTicks Construct CallCompiledObjectMethodNoArgs 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)13251131672.9230769230769257.0CPython 3.50194.46153846153845504.11538461538464Nuitka (historic)27876216316.0452.13007463279007Nuitka (master)27901607437.53846153846143452.0827239089412Nuitka (develop)27787559559.0769230769231452.2954077478415Nuitka (factory)Construct CallCompiledObjectMethodNoArgsTicks

Source Code with Construct

from __future__ import print_function

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

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

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 32  
33     inst.compiled_method() 33  
34     inst.compiled_method() 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
389     PyObject *exception_keeper_type_1; 389     PyObject *exception_keeper_type_1;
390     PyObject *exception_keeper_value_1; 390     PyObject *exception_keeper_value_1;
391     PyTracebackObject *exception_keeper_tb_1; 391     PyTracebackObject *exception_keeper_tb_1;
392     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 392     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
393     PyObject *tmp_assign_source_1; 393     PyObject *tmp_assign_source_1;
n 394     PyObject *tmp_called_instance_1; n
395     PyObject *tmp_called_instance_2;
396     PyObject *tmp_called_instance_3;
397     PyObject *tmp_called_name_1; 394     PyObject *tmp_called_name_1;
398     PyObject *tmp_return_value; 395     PyObject *tmp_return_value;
n 399     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
400     static struct Nuitka_FrameObject *cache_frame_function = NULL; 396     static struct Nuitka_FrameObject *cache_frame_function = NULL;
401 397
402     struct Nuitka_FrameObject *frame_function; 398     struct Nuitka_FrameObject *frame_function;
403 399
404     char const *type_description; 400     char const *type_description;
452         goto frame_exception_exit_1; 448         goto frame_exception_exit_1;
453     } 449     }
454     assert( var_inst == NULL ); 450     assert( var_inst == NULL );
455     var_inst = tmp_assign_source_1; 451     var_inst = tmp_assign_source_1;
456 452
n 457     tmp_called_instance_1 = var_inst; n
458  
459     frame_function->m_frame.f_lineno = 32;
460     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_1, const_str_plain_compiled_method );
461     if ( tmp_unused == NULL )
462     {
463         assert( ERROR_OCCURRED() );
464  
465         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
466  
467  
468         exception_lineno = 32;
469         type_description = "o";
470         goto frame_exception_exit_1;
471     }
472     Py_DECREF( tmp_unused );
473     tmp_called_instance_2 = var_inst;
474  
475     if ( tmp_called_instance_2 == NULL )
476     {
477  
478         exception_type = PyExc_UnboundLocalError;
479         Py_INCREF( exception_type );
480         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
481         exception_tb = NULL;
482         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
483         CHAIN_EXCEPTION( exception_value );
484  
485         exception_lineno = 33;
486         type_description = "o";
487         goto frame_exception_exit_1;
488     }
489  
490     frame_function->m_frame.f_lineno = 33;
491     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_2, const_str_plain_compiled_method );
492     if ( tmp_unused == NULL )
493     {
494         assert( ERROR_OCCURRED() );
495  
496         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
497  
498  
499         exception_lineno = 33;
500         type_description = "o";
501         goto frame_exception_exit_1;
502     }
503     Py_DECREF( tmp_unused );
504     tmp_called_instance_3 = var_inst;
505  
506     if ( tmp_called_instance_3 == NULL )
507     {
508  
509         exception_type = PyExc_UnboundLocalError;
510         Py_INCREF( exception_type );
511         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
512         exception_tb = NULL;
513         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
514         CHAIN_EXCEPTION( exception_value );
515  
516         exception_lineno = 34;
517         type_description = "o";
518         goto frame_exception_exit_1;
519     }
520  
521     frame_function->m_frame.f_lineno = 34;
522     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_3, const_str_plain_compiled_method );
523     if ( tmp_unused == NULL )
524     {
525         assert( ERROR_OCCURRED() );
526  
527         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
528  
529  
530         exception_lineno = 34;
531         type_description = "o";
532         goto frame_exception_exit_1;
533     }
534     Py_DECREF( tmp_unused );
535 453
536 #if 0 454 #if 0
537     RESTORE_FRAME_EXCEPTION( frame_function ); 455     RESTORE_FRAME_EXCEPTION( frame_function );
538 #endif 456 #endif
539 457
583     // tried codes exits in all cases 501     // tried codes exits in all cases
584     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 502     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
585     return NULL; 503     return NULL;
586     // Return handler code: 504     // Return handler code:
587     try_return_handler_1:; 505     try_return_handler_1:;
n n 506     CHECK_OBJECT( (PyObject *)var_inst );
588     Py_XDECREF( var_inst ); 507     Py_DECREF( var_inst );
589     var_inst = NULL; 508     var_inst = NULL;
590 509
591     goto function_return_exit; 510     goto function_return_exit;
592     // Exception handler code: 511     // Exception handler code:
593     try_except_handler_1:; 512     try_except_handler_1:;
597     exception_keeper_lineno_1 = exception_lineno; 516     exception_keeper_lineno_1 = exception_lineno;
598     exception_type = NULL; 517     exception_type = NULL;
599     exception_value = NULL; 518     exception_value = NULL;
600     exception_tb = NULL; 519     exception_tb = NULL;
601     exception_lineno = -1; 520     exception_lineno = -1;
t 602   t
603     Py_XDECREF( var_inst );
604     var_inst = NULL;
605 521
606     // Re-raise. 522     // Re-raise.
607     exception_type = exception_keeper_type_1; 523     exception_type = exception_keeper_type_1;
608     exception_value = exception_keeper_value_1; 524     exception_value = exception_keeper_value_1;
609     exception_tb = exception_keeper_tb_1; 525     exception_tb = exception_keeper_tb_1;