Message229961
When appending to a singly-referenced string, the interpreter tries to reallocate the string in place. This applies to both `s += 'text'` and `s = s + 'text'`. Storing to a temp variable is adding a 2nd reference, so a new string gets allocated instead. If the former is the case (i.e. the object id is the same after appending), use ctypes to check the string's cached wide-string (wchar_t *) representation:
from ctypes import *
pythonapi.PyUnicode_AsUnicode.argtypes = [py_object]
pythonapi.PyUnicode_AsUnicode.restype = c_wchar_p
print(pythonapi.PyUnicode_AsUnicode(bak_path))
The wstr cache should be cleared when the string is reallocated in place, so this is probably a dead end. |
|
Date |
User |
Action |
Args |
2014-10-24 21:46:42 | eryksun | set | recipients:
+ eryksun, tim.golden, r.david.murray, zach.ware, serhiy.storchaka, steve.dower, hosford42 |
2014-10-24 21:46:42 | eryksun | set | messageid: <1414187202.6.0.535022953689.issue22719@psf.upfronthosting.co.za> |
2014-10-24 21:46:42 | eryksun | link | issue22719 messages |
2014-10-24 21:46:42 | eryksun | create | |
|