Construct CallCompiledMethodPosArgsConstant1

Performance Diagrams

Construct CallCompiledMethodPosArgsConstant1 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000120000000120000000130000000130000000140000000140000000CPython 2.7Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)14191961072.9230769230769257.0CPython 2.752300937194.46153846153845413.0471653432206Nuitka (historic)46101977316.0423.84101113109574Nuitka (master)46101797437.53846153846143423.84132455338624Nuitka (develop)45801653559.0769230769231424.3639457753583Nuitka (factory)Construct CallCompiledMethodPosArgsConstant1Ticks Construct CallCompiledMethodPosArgsConstant1 00100000001000000020000000200000003000000030000000400000004000000050000000500000006000000060000000700000007000000080000000800000009000000090000000100000000100000000110000000110000000CPython 3.5Nuitka (historic)Nuitka (master)Nuitka (develop)Nuitka (factory)11977619272.9230769230769257.0CPython 3.50194.46153846153845504.11538461538464Nuitka (historic)49414359316.0402.1665070804594Nuitka (master)49402137437.53846153846143402.19172281140175Nuitka (develop)49401387559.0769230769231402.19327016847967Nuitka (factory)Construct CallCompiledMethodPosArgsConstant1Ticks

Source Code with Construct

from __future__ import print_function

class C:
    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:
    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
56 static PyObject *const_str_plain_x; 56 static PyObject *const_str_plain_x;
57 extern PyObject *const_tuple_empty; 57 extern PyObject *const_tuple_empty;
58 static PyObject *const_str_plain_C; 58 static PyObject *const_str_plain_C;
59 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352; 59 static PyObject *const_str_digest_5ed1392909ad16e6227b8230f4582352;
60 static PyObject *const_tuple_str_plain_inst_tuple; 60 static PyObject *const_tuple_str_plain_inst_tuple;
n 61 static PyObject *const_str_plain_some; n
62 extern PyObject *const_str_plain___loader__; 61 extern PyObject *const_str_plain___loader__;
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 extern PyObject *const_str_plain___class__; 66 extern PyObject *const_str_plain___class__;
69 static PyObject *module_filename_obj; 67 static PyObject *module_filename_obj;
70 68
94     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 168 ], 8, 0 ); 92     const_str_angle_module = UNSTREAM_STRING( &constant_bin[ 168 ], 8, 0 );
95     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 176 ], 1, 1 ); 93     const_str_plain_x = UNSTREAM_STRING( &constant_bin[ 176 ], 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[ 177 ], 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__
409     PyObject *exception_keeper_value_1; 404     PyObject *exception_keeper_value_1;
410     PyTracebackObject *exception_keeper_tb_1; 405     PyTracebackObject *exception_keeper_tb_1;
411     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 406     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
412     PyObject *tmp_assign_source_1; 407     PyObject *tmp_assign_source_1;
413     PyObject *tmp_called_name_1; 408     PyObject *tmp_called_name_1;
n 414     PyObject *tmp_called_name_2; n
415     PyObject *tmp_called_name_3;
416     PyObject *tmp_called_name_4;
417     PyObject *tmp_frame_locals; 409     PyObject *tmp_frame_locals;
418     PyObject *tmp_return_value; 410     PyObject *tmp_return_value;
n 419     PyObject *tmp_source_name_1; n
420     PyObject *tmp_source_name_2;
421     PyObject *tmp_source_name_3;
422     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused;
423     static PyFrameObject *cache_frame_function = NULL; 411     static PyFrameObject *cache_frame_function = NULL;
424 412
425     PyFrameObject *frame_function; 413     PyFrameObject *frame_function;
426 414
427     tmp_return_value = NULL; 415     tmp_return_value = NULL;
477         goto frame_exception_exit_1; 465         goto frame_exception_exit_1;
478     } 466     }
479     assert( var_inst == NULL ); 467     assert( var_inst == NULL );
480     var_inst = tmp_assign_source_1; 468     var_inst = tmp_assign_source_1;
481 469
n 482     tmp_source_name_1 = var_inst; n
483  
484     tmp_called_name_2 = LOOKUP_ATTRIBUTE( tmp_source_name_1, const_str_plain_compiled_method );
485     if ( tmp_called_name_2 == NULL )
486     {
487         assert( ERROR_OCCURRED() );
488  
489         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
490  
491  
492         exception_lineno = 32;
493         goto frame_exception_exit_1;
494     }
495     frame_function->f_lineno = 32;
496     tmp_unused = CALL_FUNCTION_WITH_ARGS1( tmp_called_name_2, &PyTuple_GET_ITEM( const_tuple_str_plain_some_tuple, 0 ) );
497  
498     Py_DECREF( tmp_called_name_2 );
499     if ( tmp_unused == NULL )
500     {
501         assert( ERROR_OCCURRED() );
502  
503         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
504  
505  
506         exception_lineno = 32;
507         goto frame_exception_exit_1;
508     }
509     Py_DECREF( tmp_unused );
510     tmp_source_name_2 = var_inst;
511  
512     if ( tmp_source_name_2 == NULL )
513     {
514  
515         exception_type = PyExc_UnboundLocalError;
516         Py_INCREF( exception_type );
517         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
518         exception_tb = NULL;
519         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
520         CHAIN_EXCEPTION( exception_value );
521  
522         exception_lineno = 33;
523         goto frame_exception_exit_1;
524     }
525  
526     tmp_called_name_3 = LOOKUP_ATTRIBUTE( tmp_source_name_2, const_str_plain_compiled_method );
527     if ( tmp_called_name_3 == 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     frame_function->f_lineno = 33;
538     tmp_unused = CALL_FUNCTION_WITH_ARGS1( tmp_called_name_3, &PyTuple_GET_ITEM( const_tuple_str_plain_some_tuple, 0 ) );
539  
540     Py_DECREF( tmp_called_name_3 );
541     if ( tmp_unused == NULL )
542     {
543         assert( ERROR_OCCURRED() );
544  
545         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
546  
547  
548         exception_lineno = 33;
549         goto frame_exception_exit_1;
550     }
551     Py_DECREF( tmp_unused );
552     tmp_source_name_3 = var_inst;
553  
554     if ( tmp_source_name_3 == NULL )
555     {
556  
557         exception_type = PyExc_UnboundLocalError;
558         Py_INCREF( exception_type );
559         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
560         exception_tb = NULL;
561         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
562         CHAIN_EXCEPTION( exception_value );
563  
564         exception_lineno = 34;
565         goto frame_exception_exit_1;
566     }
567  
568     tmp_called_name_4 = LOOKUP_ATTRIBUTE( tmp_source_name_3, const_str_plain_compiled_method );
569     if ( tmp_called_name_4 == NULL )
570     {
571         assert( ERROR_OCCURRED() );
572  
573         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
574  
575  
576         exception_lineno = 34;
577         goto frame_exception_exit_1;
578     }
579     frame_function->f_lineno = 34;
580     tmp_unused = CALL_FUNCTION_WITH_ARGS1( tmp_called_name_4, &PyTuple_GET_ITEM( const_tuple_str_plain_some_tuple, 0 ) );
581  
582     Py_DECREF( tmp_called_name_4 );
583     if ( tmp_unused == NULL )
584     {
585         assert( ERROR_OCCURRED() );
586  
587         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
588  
589  
590         exception_lineno = 34;
591         goto frame_exception_exit_1;
592     }
593     Py_DECREF( tmp_unused );
594 470
595 #if 0 471 #if 0
596     RESTORE_FRAME_EXCEPTION( frame_function ); 472     RESTORE_FRAME_EXCEPTION( frame_function );
597 #endif 473 #endif
598     // Put the previous frame back on top. 474     // Put the previous frame back on top.
664     // tried codes exits in all cases 540     // tried codes exits in all cases
665     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly ); 541     NUITKA_CANNOT_GET_HERE( __main__$$$function_1_calledRepeatedly );
666     return NULL; 542     return NULL;
667     // Return handler code: 543     // Return handler code:
668     try_return_handler_1:; 544     try_return_handler_1:;
n n 545     CHECK_OBJECT( (PyObject *)var_inst );
669     Py_XDECREF( var_inst ); 546     Py_DECREF( var_inst );
670     var_inst = NULL; 547     var_inst = NULL;
671 548
672     goto function_return_exit; 549     goto function_return_exit;
673     // Exception handler code: 550     // Exception handler code:
674     try_except_handler_1:; 551     try_except_handler_1:;
678     exception_keeper_lineno_1 = exception_lineno; 555     exception_keeper_lineno_1 = exception_lineno;
679     exception_type = NULL; 556     exception_type = NULL;
680     exception_value = NULL; 557     exception_value = NULL;
681     exception_tb = NULL; 558     exception_tb = NULL;
682     exception_lineno = -1; 559     exception_lineno = -1;
t 683   t
684     Py_XDECREF( var_inst );
685     var_inst = NULL;
686 560
687     // Re-raise. 561     // Re-raise.
688     exception_type = exception_keeper_type_1; 562     exception_type = exception_keeper_type_1;
689     exception_value = exception_keeper_value_1; 563     exception_value = exception_keeper_value_1;
690     exception_tb = exception_keeper_tb_1; 564     exception_tb = exception_keeper_tb_1;