Construct CallCompiledMethodNoArgs

Performance Diagrams

Construct CallCompiledMethodNoArgs 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)13410229472.9230769230769257.0CPython 2.750200102194.46153846153845411.60975221015866Nuitka (historic)42801062316.0425.2442439168003Nuitka (master)42801044437.53846153846143425.2442770860831Nuitka (develop)43700812559.0769230769231423.5862404578312Nuitka (factory)Construct CallCompiledMethodNoArgsTicks Construct CallCompiledMethodNoArgs 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)11345125872.9230769230769257.0CPython 3.50194.46153846153845504.11538461538464Nuitka (historic)46800988316.0402.17518268302706Nuitka (master)46800906437.53846153846143402.1753612924307Nuitka (develop)46800842559.0769230769231402.17550069489215Nuitka (factory)Construct CallCompiledMethodNoArgsTicks

Source Code with Construct

from __future__ import print_function

class C:
    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:
    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
397     PyObject *exception_keeper_value_1; 397     PyObject *exception_keeper_value_1;
398     PyTracebackObject *exception_keeper_tb_1; 398     PyTracebackObject *exception_keeper_tb_1;
399     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 399     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
400     PyObject *tmp_assign_source_1; 400     PyObject *tmp_assign_source_1;
401     PyObject *tmp_called_name_1; 401     PyObject *tmp_called_name_1;
n 402     PyObject *tmp_called_name_2; n
403     PyObject *tmp_called_name_3;
404     PyObject *tmp_called_name_4;
405     PyObject *tmp_frame_locals; 402     PyObject *tmp_frame_locals;
406     PyObject *tmp_return_value; 403     PyObject *tmp_return_value;
n 407     PyObject *tmp_source_name_1; n
408     PyObject *tmp_source_name_2;
409     PyObject *tmp_source_name_3;
410     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
411     static PyFrameObject *cache_frame_function = NULL; 404     static PyFrameObject *cache_frame_function = NULL;
412 405
413     PyFrameObject *frame_function; 406     PyFrameObject *frame_function;
414 407
415     tmp_return_value = NULL; 408     tmp_return_value = NULL;
465         goto frame_exception_exit_1; 458         goto frame_exception_exit_1;
466     } 459     }
467     assert( var_inst == NULL ); 460     assert( var_inst == NULL );
468     var_inst = tmp_assign_source_1; 461     var_inst = tmp_assign_source_1;
469 462
n 470     tmp_source_name_1 = var_inst; n
471  
472     tmp_called_name_2 = LOOKUP_ATTRIBUTE( tmp_source_name_1, const_str_plain_compiled_method );
473     if ( tmp_called_name_2 == NULL )
474     {
475         assert( ERROR_OCCURRED() );
476  
477         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
478  
479  
480         exception_lineno = 32;
481         goto frame_exception_exit_1;
482     }
483     frame_function->f_lineno = 32;
484     tmp_unused = CALL_FUNCTION_NO_ARGS( tmp_called_name_2 );
485     Py_DECREF( tmp_called_name_2 );
486     if ( tmp_unused == NULL )
487     {
488         assert( ERROR_OCCURRED() );
489  
490         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
491  
492  
493         exception_lineno = 32;
494         goto frame_exception_exit_1;
495     }
496     Py_DECREF( tmp_unused );
497     tmp_source_name_2 = var_inst;
498  
499     if ( tmp_source_name_2 == NULL )
500     {
501  
502         exception_type = PyExc_UnboundLocalError;
503         Py_INCREF( exception_type );
504         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
505         exception_tb = NULL;
506         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
507         CHAIN_EXCEPTION( exception_value );
508  
509         exception_lineno = 33;
510         goto frame_exception_exit_1;
511     }
512  
513     tmp_called_name_3 = LOOKUP_ATTRIBUTE( tmp_source_name_2, const_str_plain_compiled_method );
514     if ( tmp_called_name_3 == NULL )
515     {
516         assert( ERROR_OCCURRED() );
517  
518         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
519  
520  
521         exception_lineno = 33;
522         goto frame_exception_exit_1;
523     }
524     frame_function->f_lineno = 33;
525     tmp_unused = CALL_FUNCTION_NO_ARGS( tmp_called_name_3 );
526     Py_DECREF( tmp_called_name_3 );
527     if ( tmp_unused == NULL )
528     {
529         assert( ERROR_OCCURRED() );
530  
531         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
532  
533  
534         exception_lineno = 33;
535         goto frame_exception_exit_1;
536     }
537     Py_DECREF( tmp_unused );
538     tmp_source_name_3 = var_inst;
539  
540     if ( tmp_source_name_3 == NULL )
541     {
542  
543         exception_type = PyExc_UnboundLocalError;
544         Py_INCREF( exception_type );
545         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
546         exception_tb = NULL;
547         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
548         CHAIN_EXCEPTION( exception_value );
549  
550         exception_lineno = 34;
551         goto frame_exception_exit_1;
552     }
553  
554     tmp_called_name_4 = LOOKUP_ATTRIBUTE( tmp_source_name_3, const_str_plain_compiled_method );
555     if ( tmp_called_name_4 == NULL )
556     {
557         assert( ERROR_OCCURRED() );
558  
559         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
560  
561  
562         exception_lineno = 34;
563         goto frame_exception_exit_1;
564     }
565     frame_function->f_lineno = 34;
566     tmp_unused = CALL_FUNCTION_NO_ARGS( tmp_called_name_4 );
567     Py_DECREF( tmp_called_name_4 );
568     if ( tmp_unused == NULL )
569     {
570         assert( ERROR_OCCURRED() );
571  
572         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
573  
574  
575         exception_lineno = 34;
576         goto frame_exception_exit_1;
577     }
578     Py_DECREF( tmp_unused );
579 463
580 #if 0 464 #if 0
581     RESTORE_FRAME_EXCEPTION( frame_function ); 465     RESTORE_FRAME_EXCEPTION( frame_function );
582 #endif 466 #endif
583     // Put the previous frame back on top. 467     // Put the previous frame back on top.
649     // tried codes exits in all cases 533     // tried codes exits in all cases
650     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 534     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
651     return NULL; 535     return NULL;
652     // Return handler code: 536     // Return handler code:
653     try_return_handler_1:; 537     try_return_handler_1:;
n n 538     CHECK_OBJECT( (PyObject *)var_inst );
654     Py_XDECREF( var_inst ); 539     Py_DECREF( var_inst );
655     var_inst = NULL; 540     var_inst = NULL;
656 541
657     goto function_return_exit; 542     goto function_return_exit;
658     // Exception handler code: 543     // Exception handler code:
659     try_except_handler_1:; 544     try_except_handler_1:;
663     exception_keeper_lineno_1 = exception_lineno; 548     exception_keeper_lineno_1 = exception_lineno;
664     exception_type = NULL; 549     exception_type = NULL;
665     exception_value = NULL; 550     exception_value = NULL;
666     exception_tb = NULL; 551     exception_tb = NULL;
667     exception_lineno = -1; 552     exception_lineno = -1;
t 668   t
669     Py_XDECREF( var_inst );
670     var_inst = NULL;
671 553
672     // Re-raise. 554     // Re-raise.
673     exception_type = exception_keeper_type_1; 555     exception_type = exception_keeper_type_1;
674     exception_value = exception_keeper_value_1; 556     exception_value = exception_keeper_value_1;
675     exception_tb = exception_keeper_tb_1; 557     exception_tb = exception_keeper_tb_1;