API : constness ?
Delaney, Timothy C (Timothy)
tdelaney at avaya.com
Sun May 30 21:56:57 EDT 2004
BenoƮt Dejean wrote:
> it's also for a simple reason, eg using PyArg_ParseTupleAndKeywords
>
> using const helps gcc to move these data to the text segment
>
> static const char * const kwlist[] = { "uri", "open_mode",
> "exclusive", "perm", NULL };
Does this give any performance or size improvement?
> or a better (but tricky) storage could be used to avoid relocation
>
> bust casting again again like this
>
> PyArg_ParseTupleAndKeywords(args, kwargs, "should be const char *",
> (char**)kwlist, ...
>
> is quite ugly ...
If it will simplify calling code, I don't see any reason not to do it. However, there is a general policy of not doing large chunks of boilerplate fixing - instead it is encouraged to make these changes in code that is being actively worked on for some other reason. Small patches are good.
Perhaps you should choose a few cases that bug you the most (e.g. PyArg_ParseTupleAndKeywords) and submit a patch just for those.
Additionally, if you can show a performance improvement as a result (and importantly, no loss of performance on Windows ...) it's more likely to be reviewed kindly ... ;)
Tim Delaney
More information about the Python-list
mailing list