[sage-support] Re: using len invokes "bad" division

2009-05-04 Thread Jaap Spies
Mike Hansen wrote: > On Mon, May 4, 2009 at 12:19 PM, Jaap Spies wrote: >> Another Python builtin is pow(), but how is it possible that >> type(pow(2,9,11)) returns >> >> >> Or am I mistaken? > > The pow() builtin just calls __pow__ on the first argument in that > case, which we control so we c

[sage-support] Re: using len invokes "bad" division

2009-05-04 Thread William Stein
On Mon, May 4, 2009 at 12:23 PM, Mike Hansen wrote: > > On Mon, May 4, 2009 at 12:19 PM, Jaap Spies wrote: >> Another Python builtin is pow(), but how is it possible that >> type(pow(2,9,11)) returns >> >> >> Or am I mistaken? > > The pow() builtin just calls __pow__ on the first argument in th

[sage-support] Re: using len invokes "bad" division

2009-05-04 Thread Mike Hansen
On Mon, May 4, 2009 at 12:19 PM, Jaap Spies wrote: > Another Python builtin is pow(), but how is it possible that > type(pow(2,9,11)) returns > > > Or am I mistaken? The pow() builtin just calls __pow__ on the first argument in that case, which we control so we can return one of our types. len

[sage-support] Re: using len invokes "bad" division

2009-05-04 Thread Jaap Spies
Robert Bradshaw wrote: > On May 4, 2009, at 10:45 AM, kcrisman wrote: > len() is a Python builtin, which is a good indication that it will > return Python types (especially when acting on a Python type). In > fact, there's no way on the c-api level to return a Sage integer, as > len() alway

[sage-support] Re: using len invokes "bad" division

2009-05-04 Thread William Stein
On Mon, May 4, 2009 at 11:13 AM, kcrisman wrote: > >> >>> I assume this is known, but I am wondering whether it should be >> >>> treated as a bug, >> >> >> This is not a bug.  It's a stupid design decision in Python, which we > > Right, I knew that Python ints behaved this way, I was just surpris

[sage-support] Re: using len invokes "bad" division

2009-05-04 Thread kcrisman
> >>> I assume this is known, but I am wondering whether it should be > >>> treated as a bug, > > >> This is not a bug.  It's a stupid design decision in Python, which we Right, I knew that Python ints behaved this way, I was just surprised that somehow in Sage / didn't change this - I guess it's

[sage-support] Re: using len invokes "bad" division

2009-05-04 Thread mabshoff
On May 4, 11:01 am, Robert Bradshaw wrote: > On May 4, 2009, at 10:53 AM, William Stein wrote: > Good point, I hadn't though about that. We could introduce a size()   > or cardinality() method that returns an Integer, or possibly infinity. Combinat already uses cardinality() since they need

[sage-support] Re: using len invokes "bad" division

2009-05-04 Thread William Stein
On Mon, May 4, 2009 at 11:01 AM, Robert Bradshaw wrote: > > On May 4, 2009, at 10:53 AM, William Stein wrote: > >> On Mon, May 4, 2009 at 10:45 AM, kcrisman wrote: >>> >>> Dear support, >>> >>> I assume this is known, but I am wondering whether it should be >>> treated as a bug, >> >> This is no

[sage-support] Re: using len invokes "bad" division

2009-05-04 Thread Robert Bradshaw
On May 4, 2009, at 10:53 AM, William Stein wrote: > On Mon, May 4, 2009 at 10:45 AM, kcrisman wrote: >> >> Dear support, >> >> I assume this is known, but I am wondering whether it should be >> treated as a bug, > > This is not a bug. It's a stupid design decision in Python, which we > have to

[sage-support] Re: using len invokes "bad" division

2009-05-04 Thread Robert Bradshaw
On May 4, 2009, at 10:45 AM, kcrisman wrote: > Dear support, > > I assume this is known, but I am wondering whether it should be > treated as a bug, or whether someone using len() on lists should be > assumed to know it might then be operated on with Python /, not > Sage /, as opposed to the prep

[sage-support] Re: using len invokes "bad" division

2009-05-04 Thread William Stein
On Mon, May 4, 2009 at 10:45 AM, kcrisman wrote: > > Dear support, > > I assume this is known, but I am wondering whether it should be > treated as a bug, This is not a bug. It's a stupid design decision in Python, which we have to live with until we switch to Python 3.0 or switch to doing "fro