I've might have touched upon this one before, actually I cannot 
remember. At any rate I know I've got no answer.

Can anyone think of a reason why C string literals are allocated as 
variables in C source? I.e. what happens now is

static char __pyx_k_2[] = "AB";
static PyObject *__pyx_kp_2;
...

static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_kp_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 1, 0},
   {0, 0, 0, 0, 0, 0}
};

This leads to bookkeeping etc. in Symtab.py, and IMO also makes the C 
source less readable. Would it be possible to simplify this and instead do

static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_kp_2, "AB", 2, 0, 1, 0},
   {0, 0, 0, 0, 0, 0}
};

?

One could argue that the literal can be reused -- however the C compiler 
will in most (all?) cases optimize/collapse identical string constants 
anyway, and also Cython currently doesn't do this for StringNode, only 
identifiers...

(The background is that string literals etc. should also be moved to 
code generation, so that, say, pruning a StringNode in a transform 
doesn't make the string constant linger in the scope. Part of this is 
already in place but the final steps are not done. See 
http://trac.cython.org/cython_trac/ticket/99 )

-- 
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to