Message106240
Usually you wouldn't want to cast a char directly to a Py_UNICODE, because you need to take into account the encoding of the char and map it to the appropriate Unicode character. The exception is when you're certain the char is 7-bit ASCII, which is a subset of Unicode; that's safe since 7-bit ASCII never uses the sign bit.
However, again, I'm not an expert on the internals of Python's Unicode implementation and it's possible that I'm missing something. ;) You also raise a good point about third-party code.
Your other suggestion is quite workable. ./configure could define HAVE_USABLE_WCHAR_T (which is used to enable the optimizations) when sizeof(wchar_t) == sizeof(Py_UNICODE), yet still define Py_UNICODE as unsigned. Using Google Code I could not find any instances of HAVE_USABLE_WCHAR_T being used outside of CPython itself.
Another option would be to test Py_UNICODE_SIZE == SIZEOF_WCHAR_T to enable the optimizations, instead of defined(HAVE_USABLE_WCHAR_T). The plus side is that we wouldn't be changing the semantics of anything. |
|
Date |
User |
Action |
Args |
2010-05-21 13:55:05 | stutzbach | set | recipients:
+ stutzbach, lemburg, loewis, pitrou |
2010-05-21 13:55:05 | stutzbach | set | messageid: <1274450105.57.0.555651103047.issue8781@psf.upfronthosting.co.za> |
2010-05-21 13:55:03 | stutzbach | link | issue8781 messages |
2010-05-21 13:55:02 | stutzbach | create | |
|