Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news1.tnib.de!feed.news.tnib.de!news.tnib.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.035 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'output': 0.05; 'quiet': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:script': 0.09; 'random': 0.14; 'benjamin': 0.16; 'components.': 0.16; 'considers': 0.16; 'does,': 0.16; 'instead:': 0.16; 'kern': 0.16; 'realising': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'storing': 0.16; 'subject:random': 0.16; 'underlying': 0.16; 'wrote:': 0.18; 'thu,': 0.19; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'bytes': 0.24; 'interpret': 0.24; 'mathematical': 0.24; 'typical': 0.24; 'source': 0.25; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'external': 0.29; 'robert': 0.30; "i'm": 0.30; '+0100,': 0.31; '>>>>': 0.31; 'continually': 0.31; "d'aprano": 0.31; 'lot.': 0.31; 'steven': 0.31; 'yes.': 0.31; 'maintaining': 0.32; 'run': 0.32; 'running': 0.33; 'sources': 0.33; 'sense': 0.34; 'could': 0.34; 'but': 0.35; 'really': 0.36; 'accessible': 0.36; 'doing': 0.36; 'operating': 0.37; 'machines': 0.38; 'to:addr :python-list': 0.38; 'generating': 0.39; 'moving': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'how': 0.40; 'even': 0.60; 'is.': 0.60; 'slowly': 0.60; 'numbers': 0.61; 'skip:n 10': 0.64; 'our': 0.64; 'grab': 0.64; 'provide': 0.64; 'world': 0.66; 'believe': 0.68; 'of:': 0.68; 'electrical': 0.74; 'special': 0.74; 'eco': 0.84; 'noise': 0.84; 'oscar': 0.84; 'received:202.71': 0.84; 'subject:long': 0.84; 'terrible': 0.84; 'thermal': 0.84; 'subject:very': 0.91; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Robert Kern Subject: Re: performance of script to write very long lines of random chars Date: Thu, 11 Apr 2013 19:06:57 +0530 References: <24dc619b-7abd-4be3-aa92-f858eb4ab85f@n4g2000yqj.googlegroups.com> <51666aae$0$29977$c3e8da3$5496439d@news.astraweb.com> <51669576$0$29977$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 202.71.137.182 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 45 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1365687426 news.xs4all.nl 2634 [2001:888:2000:d::a6]:50807 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:43367 On 2013-04-11 17:35, Oscar Benjamin wrote: > On 11 April 2013 11:50, Steven D'Aprano > wrote: >> On Thu, 11 Apr 2013 10:47:43 +0100, Oscar Benjamin wrote: >> >>> On 11 April 2013 08:47, Steven D'Aprano >>> wrote: >>> >>>> One thing to be aware of: urandom may run out of entropy, and then it >>>> will slow down a lot. If you don't care about cryptographic randomness, >>>> you could use this instead: >>> >>> Reading this I'm realising that I don't really know what os.urandom is. >>> How exactly is it generating random numbers and what do you mean by it >>> running out of entropy? >> >> Some (most?) modern operating systems provide a cryptographically strong >> source of non-deterministic randomness. The non-deterministic part comes >> from external "stuff", which is called "entropy". Typical sources of >> entropy include network events, user key-presses, moving the mouse, and >> (presumably in machines with special hardware), even thermal noise in >> electrical components. > >> Entropy is used and discarded, so urandom needs the OS to continually >> replenish the amount of entropy. Under normal circumstances, this it >> does, but if you grab lots of urandom output on a system which is >> otherwise quiet and not doing anything, it could run out. > > Okay, so I understand what entropy is in the thermodynamic sense and > also in the mathematical (Shannon) sense but I'm still confused about > what it means that the OS is somehow storing entropy. Do you mean that > it is always maintaining a buffer of what it considers to be random > bytes that it slowly builds up from noise that is made accessible to > the OS from the hardware? Yes. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco