Construct CallCompiledObjectMethodPosArgsDefaults

Performance Diagrams

Construct CallCompiledObjectMethodPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000240000000240000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)24202407088.11538461538461257.0CPython 2.780200964240.03846153846155422.22728123217723Nuitka (master)80201206391.96153846153845422.227034141369Nuitka (develop)80201132543.8846153846154422.2271096980624Nuitka (factory)Construct CallCompiledObjectMethodPosArgsDefaultsTicks Construct CallCompiledObjectMethodPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)23660636688.11538461538461257.0CPython 3.580600629240.03846153846155419.9348286468401Nuitka (master)80603730391.96153846153845419.93158991400026Nuitka (develop)80600222543.8846153846154419.9352537239978Nuitka (factory)Construct CallCompiledObjectMethodPosArgsDefaultsTicks

Source Code with Construct

from __future__ import print_function

class C(object):
    def compiled_method(self, a = 1, b = 2,c = 3,d = 4,e = 5,f = 6):
        return a, b, c, d, e, f

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



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 = 1, b = 2,c = 3,d = 4,e = 5,f = 6):
        return a, b, c, d, e, f

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() n
33     inst.compiled_method()
34     inst.compiled_method()
35 # construct_alternative
36 32
37 33
t t 34  
35 # construct_alternative
36     pass
37 # construct_end
38 38
39 import itertools 39 import itertools
40 for x in itertools.repeat(None, 50000): 40 for x in itertools.repeat(None, 50000):
41     calledRepeatedly() 41     calledRepeatedly()
42 42

Context Diff of Generated Code


Construct
Baseline
373     } 373     }
374     assert( var_inst == NULL ); 374     assert( var_inst == NULL );
375     var_inst = tmp_assign_source_1; 375     var_inst = tmp_assign_source_1;
376 376
377     } 377     }
n 378     { n
379     PyObject *tmp_called_instance_1;
380     PyObject *tmp_call_result_1;
381     CHECK_OBJECT( var_inst );
382     tmp_called_instance_1 = var_inst;
383     frame_766ada09c7012fa744fe0fa8891fe686->m_frame.f_lineno = 32;
384     tmp_call_result_1 = CALL_METHOD_NO_ARGS( tmp_called_instance_1, const_str_plain_compiled_method );
385     if ( tmp_call_result_1 == NULL )
386     {
387         assert( ERROR_OCCURRED() );
388  
389         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
390  
391  
392         exception_lineno = 32;
393         type_description_1 = "o";
394         goto frame_exception_exit_1;
395     }
396     Py_DECREF( tmp_call_result_1 );
397     }
398     {
399     PyObject *tmp_called_instance_2;
400     PyObject *tmp_call_result_2;
401     if ( var_inst == NULL )
402     {
403  
404         exception_type = PyExc_UnboundLocalError;
405         Py_INCREF( exception_type );
406         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
407         exception_tb = NULL;
408         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
409         CHAIN_EXCEPTION( exception_value );
410  
411         exception_lineno = 33;
412         type_description_1 = "o";
413         goto frame_exception_exit_1;
414     }
415  
416     tmp_called_instance_2 = var_inst;
417     frame_766ada09c7012fa744fe0fa8891fe686->m_frame.f_lineno = 33;
418     tmp_call_result_2 = CALL_METHOD_NO_ARGS( tmp_called_instance_2, const_str_plain_compiled_method );
419     if ( tmp_call_result_2 == NULL )
420     {
421         assert( ERROR_OCCURRED() );
422  
423         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
424  
425  
426         exception_lineno = 33;
427         type_description_1 = "o";
428         goto frame_exception_exit_1;
429     }
430     Py_DECREF( tmp_call_result_2 );
431     }
432     {
433     PyObject *tmp_called_instance_3;
434     PyObject *tmp_call_result_3;
435     if ( var_inst == NULL )
436     {
437  
438         exception_type = PyExc_UnboundLocalError;
439         Py_INCREF( exception_type );
440         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
441         exception_tb = NULL;
442         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
443         CHAIN_EXCEPTION( exception_value );
444  
445         exception_lineno = 34;
446         type_description_1 = "o";
447         goto frame_exception_exit_1;
448     }
449  
450     tmp_called_instance_3 = var_inst;
451     frame_766ada09c7012fa744fe0fa8891fe686->m_frame.f_lineno = 34;
452     tmp_call_result_3 = CALL_METHOD_NO_ARGS( tmp_called_instance_3, const_str_plain_compiled_method );
453     if ( tmp_call_result_3 == NULL )
454     {
455         assert( ERROR_OCCURRED() );
456  
457         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
458  
459  
460         exception_lineno = 34;
461         type_description_1 = "o";
462         goto frame_exception_exit_1;
463     }
464     Py_DECREF( tmp_call_result_3 );
465     }
466 378
467 #if 0 379 #if 0
468     RESTORE_FRAME_EXCEPTION( frame_766ada09c7012fa744fe0fa8891fe686 ); 380     RESTORE_FRAME_EXCEPTION( frame_766ada09c7012fa744fe0fa8891fe686 );
469 #endif 381 #endif
470 382
521     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly ); 433     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly );
522     return NULL; 434     return NULL;
523     // Return handler code: 435     // Return handler code:
524     try_return_handler_1:; 436     try_return_handler_1:;
525     { 437     {
n n 438     CHECK_OBJECT( (PyObject *)var_inst );
526     Py_XDECREF( var_inst ); 439     Py_DECREF( var_inst );
527     var_inst = NULL; 440     var_inst = NULL;
528 441
529     } 442     }
530     { 443     {
531     goto function_return_exit; 444     goto function_return_exit;
539     exception_type = NULL; 452     exception_type = NULL;
540     exception_value = NULL; 453     exception_value = NULL;
541     exception_tb = NULL; 454     exception_tb = NULL;
542     exception_lineno = 0; 455     exception_lineno = 0;
543 456
t 544     { t
545     Py_XDECREF( var_inst );
546     var_inst = NULL;
547  
548     }
549     { 457     {
550     // Re-raise. 458     // Re-raise.
551     exception_type = exception_keeper_type_1; 459     exception_type = exception_keeper_type_1;
552     exception_value = exception_keeper_value_1; 460     exception_value = exception_keeper_value_1;
553     exception_tb = exception_keeper_tb_1; 461     exception_tb = exception_keeper_tb_1;