Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38340
| X-Received | by 10.224.175.65 with SMTP id w1mr697993qaz.7.1360230065452; Thu, 07 Feb 2013 01:41:05 -0800 (PST) |
|---|---|
| X-Received | by 10.49.58.140 with SMTP id r12mr42147qeq.35.1360230065434; Thu, 07 Feb 2013 01:41:05 -0800 (PST) |
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!p13no1098339qai.0!news-out.google.com!k2ni8440qap.0!nntp.google.com!p13no17411715qai.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.python |
| Date | Thu, 7 Feb 2013 01:41:05 -0800 (PST) |
| In-Reply-To | <87ip655qwt.fsf@dpt-info.u-strasbg.fr> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=80.28.250.164; posting-account=gpBI-woAAAC8p_P9iCoAQLtMsfa1MHAb |
| NNTP-Posting-Host | 80.28.250.164 |
| References | <9efb072f-b671-45da-bc4e-ef224b2ffe76@googlegroups.com> <87ip655qwt.fsf@dpt-info.u-strasbg.fr> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <7ee26c92-0690-4f16-afe6-ef320c1c8f12@googlegroups.com> (permalink) |
| Subject | Re: Random and fork |
| From | Julien Le Goff <julien.legoff@gmail.com> |
| Injection-Date | Thu, 07 Feb 2013 09:41:05 +0000 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-Received-Bytes | 1911 |
| Xref | csiph.com comp.lang.python:38340 |
Show key headers only | View raw
Thank you for the answers! It was much simpler than I thought. On Wednesday, 6 February 2013 17:49:06 UTC+1, Alain Ketterlin wrote: > Julien Le Goff <julien.legoff@gmail.com> writes: > > > > > Today I came accross a behaviour I did not expect in python (I am > > > using 2.7). In my program, random.random() always seemed to return the > > > same number; it turned out to be related to the fact that I was using > > > os.fork. > > > > The random number generator is initialized once, when the module is > > first imported. Forking simply duplicates the process in its current > > state, so no reinitilization occurs, both (or all) processes' generators > > are in the same state, and therefore generate the same sequence. > > > > -- Alain.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Random and fork Julien Le Goff <julien.legoff@gmail.com> - 2013-02-06 08:28 -0800
Re: Random and fork Peter Otten <__peter__@web.de> - 2013-02-06 17:47 +0100
Re: Random and fork Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2013-02-06 17:49 +0100
Re: Random and fork Julien Le Goff <julien.legoff@gmail.com> - 2013-02-07 01:41 -0800
Re: Random and fork Stephane Wirtel <stephane@wirtel.be> - 2013-02-07 14:29 +0100
csiph-web