Numpy importation in Python is sometimes very slow

Hello, I am wondering if any fellow Python developer has had the same issue which I am facing in this Fall Challenge 2020.

I am trying to use Numpy to speed up some parts of my bot’s code, in order to stay below the time limit of 50ms per turn. Usually importing this module takes around 250ms, which is ok because the time limit on first turn is 1000ms:

But sometimes it happens that the module importation takes more than 3000ms, effectively ruining my bot which times out on first turn:

Both pictures come from the same run conditions.
I could not find a way to reproduce this systematically, I would say it happens once every ten tries. When it does, another thing is that CG’s console indicates that my program wrote to standard output before reading standard input, which makes me think that Numpy may have had printed something for some reason? I don’t know.

I’m at a loss to solve this issue, any tip would be greatly appreciated, thanks!

I guess in the last case you’re measuring the time of opponent’s bot, start the timer after the first line of inputs to be more precise.

If that was the case I believe the program would be stuck on the input() command, not on “import numpy”. The first input() happens after my numpy timer indeed, and before the “start turn 1” message.

I don’t know if it’s faster but have you tried:

from numpy import ((stuff you actually use here))

?