While AWS Cloud9 (C9) IDE's Run[Alt+F5] option runs Python programs (py) twice faster then a competing compute engine, but C9 takes almost thrice longer to display output on C9's terminal, so the time advantage is lost.
However if I compile/run the same py on the C9's terminal using python[2-3] my_simple_program.py
, it shows the output instantly, after compilation.
The problem is only when displaying outputs of Run[Alt+F5] option on C9's IDE, which I would prefer to use.
The py code:
# my_simple_program.py
import time
class many_items:
def __init__(self):
self._many_random_names = [
'Vladimir Alexandrakis',
'Zampeta Bekiaris',
'Triantafyl Tsatsos',
'Melpomeni Papantoniou',
'Korina Angelis',
'Manolis Karatzas',
'Niki Kostas',
'Venetia Symeonidis',
'Kassiani Kritikou',
'Maria Stavrou'
]
def __getitem__(self, arg1):
print('__getitem__() called with argument: ' + str(arg1))
return self._many_random_names[arg1]
def __setitem__(self, arg1, arg2):
print('__setitem__() called with arguments: ' +
str(arg1) + ' and ' + arg2)
self._many_random_names[arg1] = arg2
return self._many_random_names[arg1]
# Timing
start_time = time.time()
m_items = many_items()
print(m_items[8]) # Calls __getitem__(8)
# !Calls __setitem__(8,'Nikolina Kavvadias') and passes two arguments 8 and 'Nikolina Kavvadias' plus self
m_items[8] = 'Nikolina Kavvadias'
print(m_items[8])
print("--- %s seconds ---" % (time.time() - start_time))
#AWS: < 0.0002923011779785156 secs
#Competitor: > 5.650520324707031e-05 secs
I have resolved this timelag issue by using nodemon
!
Now I have the amazing mix of C9 and blazing fast results too!
Woohoo!