[Python-Dev] PEP 393 Summer of Code Project
Torsten Becker
torsten.becker at gmail.com
Thu Aug 25 20:12:04 CEST 2011
Okay, I am convinced. :) If Martin does not object, I would change
the "void *str" field to
union {
void *any;
unsigned char *latin1;
Py_UCS2 *ucs2;
Py_UCS4 *ucs4;
} data;
Regards,
Torsten
On Wed, Aug 24, 2011 at 02:57, Stefan Behnel <stefan_ml at behnel.de> wrote:
> Torsten Becker, 24.08.2011 04:41:
>>
>> Also, common, now simple, checks for "unicode->str == NULL" would look
>> more ambiguous with a union ("unicode->str.latin1 == NULL").
>
> You could just add yet another field "any", i.e.
>
> union {
> unsigned char* latin1;
> Py_UCS2* ucs2;
> Py_UCS4* ucs4;
> void* any;
> } str;
>
> That way, the above test becomes
>
> if (!unicode->str.any)
>
> or
>
> if (unicode->str.any == NULL)
>
> Or maybe even call it "initialised" to match the intended purpose:
>
> if (!unicode->str.initialised)
>
> That being said, I don't mind "unicode->str.latin1 == NULL" either, given
> that it will (as mentioned by others) be hidden behind a macro most of the
> time anyway.
>
> Stefan
More information about the Python-Dev
mailing list