[Cython] How to know it's constant?
Stefan Behnel
stefan_ml at behnel.de
Sat Feb 2 07:50:10 CET 2008
Hi,
is there a standard way in the compiler to know (or to find out) that an
expression is constant? I noticed the "analyse_const_expression()" methods,
but they are only meant to calculate "DEF" expressions, so they raise an error
if the expression is not constant.
I'm thinking about code like this:
raise ValueError("constant")
that always raises a constant tuple with one string element that is stored in
a global constant at module init time. It would be better to store the tuple
here, not only the string. But that would require knowing that the whole tuple
is constant.
Maybe we should split "check_const()" into one part that checks the expression
and another that raises the error (if required). Or maybe pass a flag.
Stefan
More information about the Cython-dev
mailing list