Construct CallCompiledObjectMethodPosArgsDefaults

Performance Diagrams

Construct CallCompiledObjectMethodPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000240000000240000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)24202425788.11538461538461257.0CPython 2.780201234240.03846153846155422.2270688233917Nuitka (master)80201132391.96153846153845422.22717296902374Nuitka (develop)80201162543.8846153846154422.2271423379555Nuitka (factory)Construct CallCompiledObjectMethodPosArgsDefaultsTicks Construct CallCompiledObjectMethodPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)23660659088.11538461538461257.0CPython 3.580608917240.03846153846155419.92625223371846Nuitka (master)80605421391.96153846153845419.9299035072718Nuitka (develop)80597301543.8846153846154419.93838415408334Nuitka (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
298     PyObject *exception_keeper_type_1; 298     PyObject *exception_keeper_type_1;
299     PyObject *exception_keeper_value_1; 299     PyObject *exception_keeper_value_1;
300     PyTracebackObject *exception_keeper_tb_1; 300     PyTracebackObject *exception_keeper_tb_1;
301     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 301     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
302     PyObject *tmp_assign_source_1; 302     PyObject *tmp_assign_source_1;
n 303     PyObject *tmp_called_instance_1; n
304     PyObject *tmp_called_instance_2;
305     PyObject *tmp_called_instance_3;
306     PyObject *tmp_called_name_1; 303     PyObject *tmp_called_name_1;
307     PyObject *tmp_return_value; 304     PyObject *tmp_return_value;
n 308     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
309     static struct Nuitka_FrameObject *cache_frame_152aad43d21fa85e1df102f610b99c0b = NULL; 305     static struct Nuitka_FrameObject *cache_frame_152aad43d21fa85e1df102f610b99c0b = NULL;
310 306
311     struct Nuitka_FrameObject *frame_152aad43d21fa85e1df102f610b99c0b; 307     struct Nuitka_FrameObject *frame_152aad43d21fa85e1df102f610b99c0b;
312 308
313     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 309     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
361         goto frame_exception_exit_1; 357         goto frame_exception_exit_1;
362     } 358     }
363     assert( var_inst == NULL ); 359     assert( var_inst == NULL );
364     var_inst = tmp_assign_source_1; 360     var_inst = tmp_assign_source_1;
365 361
n 366     tmp_called_instance_1 = var_inst; n
367  
368     CHECK_OBJECT( tmp_called_instance_1 );
369     frame_152aad43d21fa85e1df102f610b99c0b->m_frame.f_lineno = 32;
370     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_1, const_str_plain_compiled_method );
371     if ( tmp_unused == NULL )
372     {
373         assert( ERROR_OCCURRED() );
374  
375         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
376  
377  
378         exception_lineno = 32;
379         type_description_1 = "o";
380         goto frame_exception_exit_1;
381     }
382     Py_DECREF( tmp_unused );
383     tmp_called_instance_2 = var_inst;
384  
385     if ( tmp_called_instance_2 == NULL )
386     {
387  
388         exception_type = PyExc_UnboundLocalError;
389         Py_INCREF( exception_type );
390         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
391         exception_tb = NULL;
392         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
393         CHAIN_EXCEPTION( exception_value );
394  
395         exception_lineno = 33;
396         type_description_1 = "o";
397         goto frame_exception_exit_1;
398     }
399  
400     frame_152aad43d21fa85e1df102f610b99c0b->m_frame.f_lineno = 33;
401     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_2, const_str_plain_compiled_method );
402     if ( tmp_unused == NULL )
403     {
404         assert( ERROR_OCCURRED() );
405  
406         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
407  
408  
409         exception_lineno = 33;
410         type_description_1 = "o";
411         goto frame_exception_exit_1;
412     }
413     Py_DECREF( tmp_unused );
414     tmp_called_instance_3 = var_inst;
415  
416     if ( tmp_called_instance_3 == NULL )
417     {
418  
419         exception_type = PyExc_UnboundLocalError;
420         Py_INCREF( exception_type );
421         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
422         exception_tb = NULL;
423         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
424         CHAIN_EXCEPTION( exception_value );
425  
426         exception_lineno = 34;
427         type_description_1 = "o";
428         goto frame_exception_exit_1;
429     }
430  
431     frame_152aad43d21fa85e1df102f610b99c0b->m_frame.f_lineno = 34;
432     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_3, const_str_plain_compiled_method );
433     if ( tmp_unused == NULL )
434     {
435         assert( ERROR_OCCURRED() );
436  
437         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
438  
439  
440         exception_lineno = 34;
441         type_description_1 = "o";
442         goto frame_exception_exit_1;
443     }
444     Py_DECREF( tmp_unused );
445 362
446 #if 0 363 #if 0
447     RESTORE_FRAME_EXCEPTION( frame_152aad43d21fa85e1df102f610b99c0b ); 364     RESTORE_FRAME_EXCEPTION( frame_152aad43d21fa85e1df102f610b99c0b );
448 #endif 365 #endif
449 366
498     // tried codes exits in all cases 415     // tried codes exits in all cases
499     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly ); 416     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly );
500     return NULL; 417     return NULL;
501     // Return handler code: 418     // Return handler code:
502     try_return_handler_1:; 419     try_return_handler_1:;
n n 420     CHECK_OBJECT( (PyObject *)var_inst );
503     Py_XDECREF( var_inst ); 421     Py_DECREF( var_inst );
504     var_inst = NULL; 422     var_inst = NULL;
505 423
506     goto function_return_exit; 424     goto function_return_exit;
507     // Exception handler code: 425     // Exception handler code:
508     try_except_handler_1:; 426     try_except_handler_1:;
512     exception_keeper_lineno_1 = exception_lineno; 430     exception_keeper_lineno_1 = exception_lineno;
513     exception_type = NULL; 431     exception_type = NULL;
514     exception_value = NULL; 432     exception_value = NULL;
515     exception_tb = NULL; 433     exception_tb = NULL;
516     exception_lineno = 0; 434     exception_lineno = 0;
t 517   t
518     Py_XDECREF( var_inst );
519     var_inst = NULL;
520 435
521     // Re-raise. 436     // Re-raise.
522     exception_type = exception_keeper_type_1; 437     exception_type = exception_keeper_type_1;
523     exception_value = exception_keeper_value_1; 438     exception_value = exception_keeper_value_1;
524     exception_tb = exception_keeper_tb_1; 439     exception_tb = exception_keeper_tb_1;