5 ms·
I'm not a Python geek, but I found the C implementation for unicode strings in CPython really interesting code reading: http://hg.python.org/cpython/file/tip/O
by twoodfin 13y ago
I'm not a Python geek, but I found the C implementation for unicode strings in CPython really interesting code reading:
http://hg.python.org/cpython/file/tip/Objects/unicodeobject.c http://hg.python.org/cpython/file/tip/Objects/unicodeobject....
CPython supports several internal representations from one to four bytes per character to optimize for space and performance. There's also a nifty sort of Bloom filter for quick discrimination of strings that might contain characters of interest.
- gsnedders 13y agoThat's new in Python 3.3, which doesn't fall foul of that bug. This is PEP 393 (http://www.python.org/dev/peps/pep-0393/ http://www.python.org/dev/peps/pep-0393/) if you want more reading about it.