Make a unique filesystem path, without creating the file

Chris Angelico rosuav at gmail.com
Mon Feb 22 19:33:55 EST 2016


On Tue, Feb 23, 2016 at 11:26 AM, Jon Ribbens
<jon+usenet at unequivocal.co.uk> wrote:
> On 2016-02-23, Chris Angelico <rosuav at gmail.com> wrote:
>> On Tue, Feb 23, 2016 at 11:08 AM, Jon Ribbens
>><jon+usenet at unequivocal.co.uk> wrote:
>>>> If you generate 2**128 + 1 such numbers, you are *guaranteed* to
>>>
>>> ... have expired due to the heat death of the universe.
>>
>> Maybe... but by the time you get to 2**64 of them, you have a 50%
>> chance of a collision. (That's either utterly intuitive or completely
>> counter-intuitive, depending on who you are.)
>
> Um, did you mean to say 2**127? Are you thinking of the
> birthday paradox or something, which doesn't apply here?

By the time you generate 2**64 of them, you have a 50% chance that
some pair of them collides. Yes, the birthday paradox does apply here.

ChrisA


More information about the Python-list mailing list