API : constness ?

Benoît Dejean bnet at ifrance.com
Tue Jun 1 20:47:51 CEST 2004

Le Tue, 01 Jun 2004 09:29:11 -0700, Erik Max Francis a écrit :

> Isaac To wrote:
>> This is not quite right.  A string literal is always put into
>> read-only
>> memory, no matter whether you specify const or not.

true. but the pointer to it isn't

and i was talking of a const char * kwlist[] { }
obvious optimization is to declare kwlist as static. but when the module
is loade, kwlist gets initialize. adding another const tags the whole
kwlist as const and then totally readonly. therefor, your compiler is
able to store kwlist (the array) in a RO segment.

More information about the Python-list mailing list