Construct CallCompiledObjectMethodPosArgsDefaults

Performance Diagrams

Construct CallCompiledObjectMethodPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 2.7Nuitka (master)Nuitka (develop)Nuitka (factory)22844470388.11538461538461257.0CPython 2.779901814240.03846153846155417.6832317189486Nuitka (master)79900836391.96153846153845417.6842896504435Nuitka (develop)79900374543.8846153846154417.68478940949325Nuitka (factory)Construct CallCompiledObjectMethodPosArgsDefaultsTicks Construct CallCompiledObjectMethodPosArgsDefaults 002000000020000000400000004000000060000000600000008000000080000000100000000100000000120000000120000000140000000140000000160000000160000000180000000180000000200000000200000000220000000220000000CPython 3.5Nuitka (master)Nuitka (develop)Nuitka (factory)23436063588.11538461538461257.0CPython 3.580301346240.03846153846155419.44375022626Nuitka (master)80308086391.96153846153845419.4366434111914Nuitka (develop)80310844543.8846153846154419.4337353109007Nuitka (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
288     PyObject *exception_keeper_type_1; 288     PyObject *exception_keeper_type_1;
289     PyObject *exception_keeper_value_1; 289     PyObject *exception_keeper_value_1;
290     PyTracebackObject *exception_keeper_tb_1; 290     PyTracebackObject *exception_keeper_tb_1;
291     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1; 291     NUITKA_MAY_BE_UNUSED int exception_keeper_lineno_1;
292     PyObject *tmp_assign_source_1; 292     PyObject *tmp_assign_source_1;
n 293     PyObject *tmp_called_instance_1; n
294     PyObject *tmp_called_instance_2;
295     PyObject *tmp_called_instance_3;
296     PyObject *tmp_called_name_1; 293     PyObject *tmp_called_name_1;
297     PyObject *tmp_return_value; 294     PyObject *tmp_return_value;
n 298     NUITKA_MAY_BE_UNUSED PyObject *tmp_unused; n
299     static struct Nuitka_FrameObject *cache_frame_fe5da1d94ad68b798ff6915ec4338d4d = NULL; 295     static struct Nuitka_FrameObject *cache_frame_fe5da1d94ad68b798ff6915ec4338d4d = NULL;
300 296
301     struct Nuitka_FrameObject *frame_fe5da1d94ad68b798ff6915ec4338d4d; 297     struct Nuitka_FrameObject *frame_fe5da1d94ad68b798ff6915ec4338d4d;
302 298
303     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL; 299     NUITKA_MAY_BE_UNUSED char const *type_description_1 = NULL;
351         goto frame_exception_exit_1; 347         goto frame_exception_exit_1;
352     } 348     }
353     assert( var_inst == NULL ); 349     assert( var_inst == NULL );
354     var_inst = tmp_assign_source_1; 350     var_inst = tmp_assign_source_1;
355 351
n 356     tmp_called_instance_1 = var_inst; n
357  
358     CHECK_OBJECT( tmp_called_instance_1 );
359     frame_fe5da1d94ad68b798ff6915ec4338d4d->m_frame.f_lineno = 32;
360     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_1, const_str_plain_compiled_method );
361     if ( tmp_unused == NULL )
362     {
363         assert( ERROR_OCCURRED() );
364  
365         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
366  
367  
368         exception_lineno = 32;
369         type_description_1 = "o";
370         goto frame_exception_exit_1;
371     }
372     Py_DECREF( tmp_unused );
373     tmp_called_instance_2 = var_inst;
374  
375     if ( tmp_called_instance_2 == NULL )
376     {
377  
378         exception_type = PyExc_UnboundLocalError;
379         Py_INCREF( exception_type );
380         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
381         exception_tb = NULL;
382         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
383         CHAIN_EXCEPTION( exception_value );
384  
385         exception_lineno = 33;
386         type_description_1 = "o";
387         goto frame_exception_exit_1;
388     }
389  
390     frame_fe5da1d94ad68b798ff6915ec4338d4d->m_frame.f_lineno = 33;
391     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_2, const_str_plain_compiled_method );
392     if ( tmp_unused == NULL )
393     {
394         assert( ERROR_OCCURRED() );
395  
396         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
397  
398  
399         exception_lineno = 33;
400         type_description_1 = "o";
401         goto frame_exception_exit_1;
402     }
403     Py_DECREF( tmp_unused );
404     tmp_called_instance_3 = var_inst;
405  
406     if ( tmp_called_instance_3 == NULL )
407     {
408  
409         exception_type = PyExc_UnboundLocalError;
410         Py_INCREF( exception_type );
411         exception_value = PyUnicode_FromFormat( "local variable '%s' referenced before assignment", "inst" );
412         exception_tb = NULL;
413         NORMALIZE_EXCEPTION( &exception_type, &exception_value, &exception_tb );
414         CHAIN_EXCEPTION( exception_value );
415  
416         exception_lineno = 34;
417         type_description_1 = "o";
418         goto frame_exception_exit_1;
419     }
420  
421     frame_fe5da1d94ad68b798ff6915ec4338d4d->m_frame.f_lineno = 34;
422     tmp_unused = CALL_METHOD_NO_ARGS( tmp_called_instance_3, const_str_plain_compiled_method );
423     if ( tmp_unused == NULL )
424     {
425         assert( ERROR_OCCURRED() );
426  
427         FETCH_ERROR_OCCURRED( &exception_type, &exception_value, &exception_tb );
428  
429  
430         exception_lineno = 34;
431         type_description_1 = "o";
432         goto frame_exception_exit_1;
433     }
434     Py_DECREF( tmp_unused );
435 352
436 #if 0 353 #if 0
437     RESTORE_FRAME_EXCEPTION( frame_fe5da1d94ad68b798ff6915ec4338d4d ); 354     RESTORE_FRAME_EXCEPTION( frame_fe5da1d94ad68b798ff6915ec4338d4d );
438 #endif 355 #endif
439 356
488     // tried codes exits in all cases 405     // tried codes exits in all cases
489     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly ); 406     NUITKA_CANNOT_GET_HERE( __main__$$$function_2_calledRepeatedly );
490     return NULL; 407     return NULL;
491     // Return handler code: 408     // Return handler code:
492     try_return_handler_1:; 409     try_return_handler_1:;
n n 410     CHECK_OBJECT( (PyObject *)var_inst );
493     Py_XDECREF( var_inst ); 411     Py_DECREF( var_inst );
494     var_inst = NULL; 412     var_inst = NULL;
495 413
496     goto function_return_exit; 414     goto function_return_exit;
497     // Exception handler code: 415     // Exception handler code:
498     try_except_handler_1:; 416     try_except_handler_1:;
502     exception_keeper_lineno_1 = exception_lineno; 420     exception_keeper_lineno_1 = exception_lineno;
503     exception_type = NULL; 421     exception_type = NULL;
504     exception_value = NULL; 422     exception_value = NULL;
505     exception_tb = NULL; 423     exception_tb = NULL;
506     exception_lineno = 0; 424     exception_lineno = 0;
t 507   t
508     Py_XDECREF( var_inst );
509     var_inst = NULL;
510 425
511     // Re-raise. 426     // Re-raise.
512     exception_type = exception_keeper_type_1; 427     exception_type = exception_keeper_type_1;
513     exception_value = exception_keeper_value_1; 428     exception_value = exception_keeper_value_1;
514     exception_tb = exception_keeper_tb_1; 429     exception_tb = exception_keeper_tb_1;