Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #17917
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!news-transit.tcx.org.uk!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.006 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'bits': 0.07; 'option,': 0.07; 'url:py': 0.07; '32-bit': 0.09; 'subject:string': 0.09; 'am,': 0.12; 'received:209.85.210.174': 0.13; 'received:mail- iy0-f174.google.com': 0.13; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'justify': 0.16; 'random.': 0.16; 'url:hg': 0.16; 'mon,': 0.16; 'wrote:': 0.18; 'int': 0.18; 'source.': 0.18; 'tells': 0.21; 'dec': 0.22; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; '64-bit': 0.23; 'happen.': 0.23; 'random': 0.28; 'bit': 0.28; 'message-id:@mail.gmail.com': 0.28; 'anyway.': 0.29; 'source,': 0.29; 'chris': 0.30; 'subject:?': 0.31; "i've": 0.31; 'source': 0.31; 'does': 0.32; 'sufficient': 0.32; 'pretty': 0.32; "can't": 0.32; 'actually': 0.33; 'that,': 0.33; 'url:default': 0.34; 'to:addr:python-list': 0.34; 'url:python': 0.36; 'file': 0.36; 'two': 0.37; 'received:google.com': 0.37; 'doing': 0.38; 'steven': 0.38; 'received:209.85': 0.38; 'easier': 0.38; 'url:org': 0.39; 'define': 0.39; "it's": 0.40; 'received:209': 0.40; 'to:addr:python.org': 0.40; '2011': 0.61; '26,': 0.67; 'anything,': 0.73; 'guaranteed': 0.77; 'clearer': 0.84; 'url:lib': 0.84; 'underneath': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=S2Cs3SjObGz3NfbkOY4zs3fw4XZJISVUEJ4ZBmkJQM0=; b=R0jxLv7hx57X4/FR6lpy4JfU9H5+MUOY7xykGxtwmJQKRxnxRarLSL76xnV8MDDRnJ c4rLXSTOHY4zeMp0dGJyoL0O45KvRNH1owobSytEUXRtyo8uTlAnsjA3hLQWfgbCrZj3 gVsE+aIYei7rzP5Ruf4OCS9FxFVTPQw6XP3Ks= |
| MIME-Version | 1.0 |
| In-Reply-To | <4ef74572$0$29973$c3e8da3$5496439d@news.astraweb.com> |
| References | <roy-EDF7D2.08304625122011@news.panix.com> <4ef7299f$0$29973$c3e8da3$5496439d@news.astraweb.com> <mailman.4070.1324821283.27778.python-list@python.org> <4ef74572$0$29973$c3e8da3$5496439d@news.astraweb.com> |
| Date | Mon, 26 Dec 2011 03:11:56 +1100 |
| Subject | Re: Random string of digits? |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4077.1324829519.27778.python-list@python.org> (permalink) |
| Lines | 23 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1324829519 news.xs4all.nl 6933 [2001:888:2000:d::a6]:51348 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:17917 |
Show key headers only | View raw
On Mon, Dec 26, 2011 at 2:46 AM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > Use the Source, Luke, er, Chris :) > > If I've read the source correctly, randint() will generate sufficient > bits of randomness to ensure that the entire int is random. > > http://hg.python.org/cpython/file/default/Lib/random.py I prefer not to rely on the source. That tells me what happens, not what's guaranteed to happen. However... bit of poking around can't hurt. That file doesn't actually justify anything, because random.Random() does not define getrandbits() - that, it seems, comes from _random(); turns out that getrandbits is actually doing pretty much the same thing I suggested: http://hg.python.org/cpython/file/745f9fd9856d/Modules/_randommodule.c#l371 Need a 64-bit random number? Take two 32-bit numbers and concatenate. So, it's going to be easier and clearer to just take the simple option, since it's actually doing the same thing underneath anyway. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Random string of digits? Roy Smith <roy@panix.com> - 2011-12-25 08:30 -0500
Re: Random string of digits? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-25 13:48 +0000
Re: Random string of digits? Chris Angelico <rosuav@gmail.com> - 2011-12-26 00:54 +1100
Re: Random string of digits? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-25 15:46 +0000
Re: Random string of digits? Chris Angelico <rosuav@gmail.com> - 2011-12-26 03:11 +1100
Re: Random string of digits? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-25 17:18 +0000
Re: Random string of digits? Roy Smith <roy@panix.com> - 2011-12-25 12:41 -0500
Re: Random string of digits? 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-25 11:50 -0800
Re: Random string of digits? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-26 03:00 +0000
Re: Random string of digits? Chris Angelico <rosuav@gmail.com> - 2011-12-26 14:43 +1100
Re: Random string of digits? Roy Smith <roy@panix.com> - 2011-12-25 23:17 -0500
Re: Random string of digits? Chris Angelico <rosuav@gmail.com> - 2011-12-26 15:26 +1100
Re: Random string of digits? Serhiy Storchaka <storchaka@gmail.com> - 2011-12-25 19:32 +0200
Re: Random string of digits? Chris Angelico <rosuav@gmail.com> - 2011-12-26 00:50 +1100
Re: Random string of digits? Roy Smith <roy@panix.com> - 2011-12-25 09:21 -0500
Re: Random string of digits? Chris Angelico <rosuav@gmail.com> - 2011-12-26 01:51 +1100
Re: Random string of digits? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-25 15:27 +0000
Re: Random string of digits? Chris Angelico <rosuav@gmail.com> - 2011-12-26 00:51 +1100
Re: Random string of digits? Peter Otten <__peter__@web.de> - 2011-12-25 16:21 +0100
csiph-web