rotor alternative?
Peter Hansen
peter at engcorp.com
Thu Nov 20 19:02:59 EST 2003
Paul Rubin wrote:
>
> Peter Hansen <peter at engcorp.com> writes:
> > The docs for Py2.3 say:
> > """On Windows, this function returns wall-clock
> > seconds elapsed since the first call to this function, as a floating
> > point number, based on the Win32 function QueryPerformanceCounter().
> > The resolution is typically better than one microsecond. """
> >
> > I wonder if the part about "since the first call to this function" would
> > make this dangerous for your purposes.
>
> I don't run Windows and don't want to use something Windows specific.
> Although, "since the first call to this function" is probably ok. All
> that's needed is to get a unique number to initialize the internal
> PRNG with. Hopefully sometime, the Python library will include a C
> extension to get secure random numbers from the Windows Crypto API.
> On *nix, they are already generally available from /dev/urandom.
It just struck me that if it's the first call to the function during
a given program invocation which matters (as opposed to during a power-on
cycle of the whole PC), then it seems possible that you'll get exactly the
same valueeach time you call it if it's called only once by the program.
-Peter
More information about the Python-list
mailing list