Perhaps we have a different defination of the word, to me FUD is spreading misinformation to cause harm or manipulate people. I’m happy to admit I was wrong and the material effect is similar but I had no intention of causing harm. Throwing insults about just makes things toxic.
I’m genuinely sorry for wasting your time, but it seems unreasonable to ascribe malice to my ignorance
If you want to call it ignorance rather than malice, then the responsibility is on you to check your facts befoer you make bald assertions. Telling people that the random module is “not a good goto” is exactly FUD. Very very few people actually invent false information with malicious intent; huge numbers of people spread it.
I really don’t have the energy Tim. I joined to add to a conversation where I thought I could offer some insight, looking back my tone and delivery were definitely quite flawed. I really appreciate having been corrected, I just don’t get why I’m being accused of being a malicious spreader of deliberately misleading information that wasn’t my intention though I guess I can understand how having to deal with posts like mine on the day to day can frustrate a person.
regardless I think this forum really isn’t for me so please go ahead with the closure.
When a new user arrives on the scene and posts for the first time, other users like myself see a message reminding us to welcome the new user. For example, your first post has this message above it:
This is the first time Rob has posted — let’s welcome them to our community!
So, welcome to the Python community, Rob!
As in my case upon arrival a few years ago, you may see some messages from the discobot, inviting you to respond in order to learn more about this forum. When done, you’ll even get a certificate to hang on your wall. There’s also an advanced tutorial. So, please stick around, find out what discobot has to show you, see what good stuff is going on around here in the various categories, and have a good time!
Except you used the acronym FUD, which, as the definition @rfletchr quoted, is generally understood to mean deliberate deception. Which wasn’t the case here. An emotionally loaded characterization of a technical misunderstanding was simply inappropriate, and it’s not hard at all to understand why @rfletchr took offense.
For the technical content, you’re right: there’s every reason to believe randrange(2**128) in Python is less likely to yield a duplicate than uuid4(). It’s certain that either way will eventually deliver duplicates. And there are much simpler ways to guarantee uniqueness that don’t involve randomness at all.
@rfletchr added value to the last point by posting a simple function to do so, and I added by giving a one-liner way that’s also thread-safe.
from timeit import repeat
for e in [
'randrange(2**128)',
'getrandbits(128)',
] * 3:
t = min(repeat(e, 'from random import randrange, getrandbits', number=10**5)) / 10**5
print(f'{t*1e6:.2f} μs ', e)