[Python-Dev] PEP 393: Special-casing ASCII-only strings
Victor Stinner
victor.stinner at haypocalc.com
Thu Sep 15 23:04:16 CEST 2011
Le jeudi 15 septembre 2011 17:50:41, Martin v. Löwis a écrit :
> In reviewing memory usage, I found potential for saving more memory for
> ASCII-only strings. (...)
>
> typedef struct {
> PyObject_HEAD
> Py_ssize_t length;
> union {
> void *any;
> Py_UCS1 *latin1;
> Py_UCS2 *ucs2;
> Py_UCS4 *ucs4;
> } data;
> Py_hash_t hash;
> int state; /* may include SSTATE_SHORT_ASCII flag */
> wchar_t *wstr;
> } PyASCIIObject;
I like it. If we start which such optimization, we can also also remove data
from strings allocated by the new API (it can be computed: object pointer +
size of the structure). See my email for my proposition of structures:
Re: [Python-Dev] PEP 393 review
Thu Aug 25 00:29:19 2011
You may reorganize fields to be able to cast PyUnicodeObject to PyASCIIObject.
Victor
More information about the Python-Dev
mailing list