def test():
then = time.time() # get time at the moment
x = 0
while time.time() <= then+1: # stop looping after 1 second
x += 1
time.sleep(0.001) # sleep for 1 ms
print(x)
On windows 7 / Python 3.8 returned 1000
for me, even if i set the sleep value to 0.0005
so a perfect 1ms