[sage-devel] Re: Using .variables()/.arguments() is an anti-pattern

2008-09-09 Thread Nick Alexander
>> 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

[sage-devel] Re: Using .variables()/.arguments() is an anti-pattern

2008-09-09 Thread John Cremona
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

[sage-devel] Re: Using .variables()/.arguments() is an anti-pattern

2008-09-08 Thread Jason Merrill
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