Araq/Nimrod — pull request #1042 by ithkuil (2014-03-27 02:03:49+00:00)
Title: Calling randomize() again within 1 second will now provide a different seed

To generate a seed for randomize() with no seed specified, the existing code uses gettime() which is the C time() function that uses only seconds resolution. So calling randomize() again within one second gives the same seed and the same set of numbers. This causes a problem in cases where randomize() is called again at about the same time. For example, I was trying to generate a random API key in a command line program, and if I ran my program twice in quick succession the same API key was generated.

This changes the randomize() function to use epochTime from the times module for the seed. epochTime has a higher resolution than gettime. Testing on my computer now always results in a new seed/set of random numbers when randomize() is called in quick succession.