Message255257
> Why do strings cache their UTF-8 encoding?
Mainly for compatibility with existing C API. Common way to parse function arguments in implemented in C function is to use special argument parsing API: PyArg_ParseTuple, PyArg_ParseTupleAndKeywords, or PyArg_Parse. Most format codes for Unicode strings returned a C pointer to char array. For that encoded Unicode strings should be kept somewhere at least for the time of executing C function. As well as PyArg_Parse* functions doesn't allow user to specify a storage for encoded string, it should be saved in Unicode object. That is not new to PEP 393 or Python 3, in Python 2 the Unicode objects also keep cached encoded version. |
|
Date |
User |
Action |
Args |
2015-11-24 09:07:54 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, lemburg, terry.reedy, pitrou, vstinner, larry, benjamin.peterson, ezio.melotti, steven.daprano, eryksun, random832, Árpád Kósa |
2015-11-24 09:07:54 | serhiy.storchaka | set | messageid: <1448356074.5.0.156865369935.issue25709@psf.upfronthosting.co.za> |
2015-11-24 09:07:54 | serhiy.storchaka | link | issue25709 messages |
2015-11-24 09:07:54 | serhiy.storchaka | create | |
|