>> Since this is so short, in practice there is probably no need to
>> define the function is_constant.
No! This function declares intent, and that is always valuable.
Nick
--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To
2008/9/9 Jason Merrill <[EMAIL PROTECTED]>:
>
>
> def is_constant(f):
>return SR(f).number_of_arguments() == 0
>
> Since this is so short, in practice there is probably no need to
> define the function is_constant. If f can't be coerced to the
> symbolic ring, this will throw a TypeError, but
On Sep 8, 7:42 pm, Jason Merrill <[EMAIL PROTECTED]> wrote:
> One additional consideration is that it is useful in this case to know
> whether an expression is constant, as a performance consideration.
> The regular algorithm works (slowly) on constant input, but it's
> faster if we can just sh