1

I am generating UUIDs as follows:

import uuid
uuid.uuid4().hex

Here are some of generated UUIDs (from different machines and different Python versions):

fe072a0a2a59433f9593e21bb4cc2c5f
3c1757516dfd411aad8a5d0291f92bb5
3b12a39e9d1a4cd2a43aa0c4aee41905
            

I notice that digit 4 is always in the same position within UUID.

My understanding is that UUID tokens, in accordance with RFC4122, should guarantee "uniqueness across space and time".

Is it a bug or a feature?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
aboev
  • 332
  • 2
  • 9
  • 3
    That's the UUID version. The UUID format is: `xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx`, where `M` is the version and `N` is the variant. – rid Sep 27 '22 at 08:18
  • @rid Sounds like a correct answer, would you like to post it? – aboev Sep 27 '22 at 08:19
  • 1
    That fixed digit does not violate "uniqueness across space and time" at all… – deceze Sep 27 '22 at 08:19
  • 1
    It's a [v**4** UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random)), and that's where the version bits go... – jonrsharpe Sep 27 '22 at 08:19

0 Answers0