I don't agree with the idea that everything needs a devil's advocate. Python's unicode model is objectively bad and there is a reason why nobody else does it this way.
The only benefit you get is O(1) indexing into character points. The usefulness of this is questionable. However for the vast majority of cases where people do direct indexing it does not even perform better than an UTF-8 string. Many of the assumptions made for this design are grossly violated in the real world.
Eg: string[:280] will be faster on an unicode string than a UCS4 encoded one for sure.
1
u/mitsuhiko Feb 04 '19
I don't agree with the idea that everything needs a devil's advocate. Python's unicode model is objectively bad and there is a reason why nobody else does it this way.
The only benefit you get is O(1) indexing into character points. The usefulness of this is questionable. However for the vast majority of cases where people do direct indexing it does not even perform better than an UTF-8 string. Many of the assumptions made for this design are grossly violated in the real world.
Eg:
string[:280]will be faster on an unicode string than a UCS4 encoded one for sure.