[Python-ideas] Pre-PEP Adding A Secrets Module To The Standard Library
Serhiy Storchaka
storchaka at gmail.com
Sun Sep 20 08:00:08 CEST 2015
On 20.09.15 02:40, Tim Peters wrote:
> No attempt to be minimal here. More-than-less "obvious" is more important:
>
> Bound methods of a SystemRandom instance
> .randrange()
> .randint()
> .randbits()
> renamed from .getrandbits()
> .randbelow(exclusive_upper_bound)
> renamed from private ._randbelow()
> .choice()
randbelow() is just an alias for randrange() with single argument.
randint(a, b) == randrange(a, b+1).
These functions are redundant and they have non-zero cost.
Would not renaming getrandbits be confused?
> Token functions
> .token_bytes(nbytes)
> another name for os.urandom()
> .token_hex(nbytes)
> same, but return string of ASCII hex digits
> .token_url(nbytes)
> same, but return URL-safe base64-encoded ASCII
> .token_alpha(alphabet, nchars)
> string of `nchars` characters drawn uniformly
> from `alphabet`
token_hex(nbytes) == token_alpha('0123456789abcdef', nchars) ?
token_url(nbytes) == token_alpha(
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',
nchars) ?
More information about the Python-ideas
mailing list