I'm developing a python application on a raspberry pi 3B+ and noticed it takes quite a bit of time to import boto3 (AWS sdk) into the app.
Looking into the logs i found that importing boto3 takes approximately 17 seconds (!). This seemed way to big to be true, so I wrote a small script to test this theory:
import time
def imp_bot():
x = time.time()
import boto3
print(time.time()-x)
imp_bot()
imp_bot()
imp_bot()
I ran this script as follows:
time sudo python3 test.py
The first output after a reboot is as follows.:
16.336801290512085
3.814697265625e-06
2.6226043701171875e-06
real 0m17.128s
user 0m1.212s
sys 0m0.233s
The second time i run the script, I get somewhat more normal results:
0.8146989345550537
2.6226043701171875e-06
6.198883056640625e-06
real 0m1.155s
user 0m0.991s
sys 0m0.162s
Both python and time indicate a duration of 16 seconds. Now comes the big problem: I timed the execution with my stopwatch and in reality the first script ran only 3 seconds!!
Does anybody have any clue why is this happening? why is the timing off by 13 seconds? Did I time travel?