News for hackers. Stuff that matters.
Re:WTFPython – Understanding Python through surprising snippets by bjoli on Monday December 23, 2019 @06:49AM (#21863049)
Encoding strings internally as UTF-8 is a bad idea, since you can't do efficient constant time access (utf-8 isn't fixed width).
Re:WTFPython – Understanding Python through surprising snippets by heinrich5991 on Monday December 23, 2019 @07:00AM (#21863098)
Encoding strings internally as UTF-8 is a fine idea, usually you don't need constant-time access to individual code points. E.g. PyPy (faster Python, with JIT) does so. Many other languages also save strings as UTF-8.
Re:WTFPython – Understanding Python through surprising snippets by bjoli on Monday December 23, 2019 @07:20AM (#21863171)
And then you have to either re-train them to use string cursors or you have lots of people writing inefficient string code.
Re:WTFPython – Understanding Python through surprising snippets by heinrich5991 on Monday December 23, 2019 @09:35AM (#21863797)
Not really, no. PyPy demonstrates that.
Re:WTFPython – Understanding Python through surprising snippets by bjoli on Monday December 23, 2019 @01:11PM (#21865612)
Sure it does. Where CPython does byte inflation to make sure random access works, PyPy makes you use an extra indexing structure for cases where you can't just advance one char at a time.

I must say it is a rather elegant way, but it still fits firmly within "a new way or inefficient code".