Re: [Python-3000] Should len() clip to sys.maxsize or raise OverflowError?

2008-09-02 Thread Guido van Rossum
On Sat, Aug 30, 2008 at 8:07 AM, Hagen Fürstenau <[EMAIL PROTECTED]> wrote: > While __len__() is allowed to return a value of any size, issues 2723 > and 3729 need a decision on what len() should do if the value doesn't > fit in a Py_ssize_t. > > In a previous thread > (http://mail.python.org/piper

Re: [Python-3000] Should len() clip to sys.maxsize or raise OverflowError?

2008-09-02 Thread Daniel Stutzbach
On Tue, Sep 2, 2008 at 12:26 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote: > I stand by my view. I might voice strong discomfort with raising an > exception because it doesn't fit in some implementation detail. Isn't that precisely what OverflowError is for? ("it doesn't fit in some implementat

Re: [Python-3000] Should len() clip to sys.maxsize or raise OverflowError?

2008-09-02 Thread Guido van Rossum
On Tue, Sep 2, 2008 at 11:14 AM, Daniel Stutzbach <[EMAIL PROTECTED]> wrote: > On Tue, Sep 2, 2008 at 12:26 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote: >> I stand by my view. I might voice strong discomfort with raising an >> exception because it doesn't fit in some implementation detail. > > I

Re: [Python-3000] Should len() clip to sys.maxsize or raiseOverflowError?

2008-09-02 Thread Raymond Hettinger
From: "Guido van Rossum" <[EMAIL PROTECTED]> The way I see it is that there are tons of ways I can think of how raising OverflowError can break unsuspecting programs (e.g. code that has been tested before but never with a humungous input), whereas returning a "little white lie" would allow such c

Re: [Python-3000] Should len() clip to sys.maxsize or raiseOverflowError?

2008-09-02 Thread Guido van Rossum
On Tue, Sep 2, 2008 at 12:08 PM, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > From: "Guido van Rossum" <[EMAIL PROTECTED]> >> >> The way I see it is that there are tons of ways I can think of how >> raising OverflowError can break unsuspecting programs (e.g. code that >> has been tested before bu

Re: [Python-3000] Should len() clip to sys.maxsize or raiseOverflowError?

2008-09-02 Thread Dj Gilcrease
why would it raise an index error when log_entries has more indicies then sys.maxsize, it should just check the entry @ sys.maxsize. Maybe I missed it, but why cant len just return an int, which if I remember correctly is now a long in py3k, so on a 64 bit system len would (hopefully) never lie, b

Re: [Python-3000] Should len() clip to sys.maxsize or raiseOverflowError?

2008-09-02 Thread Raymond Hettinger
That makes sense to me and there a probably plenty of examples. However, I worry more about other examples that will fail and do so it a way that is nearly impossible to find through code review (because the code IS correct as written). n = len(log_entries) if log_entries[n] in handled: This

Re: [Python-3000] Should len() clip to sys.maxsize or raiseOverflowError?

2008-09-02 Thread Guido van Rossum
On Tue, Sep 2, 2008 at 1:35 PM, Raymond Hettinger <[EMAIL PROTECTED]> wrote: >>> That makes sense to me and there a probably plenty of examples. >>> However, I worry more about other examples that will fail >>> and do so it a way that is nearly impossible to find through >>> code review (because th

Re: [Python-3000] Should len() clip to sys.maxsize or raiseOverflowError?

2008-09-02 Thread Daniel Stutzbach
On Tue, Sep 2, 2008 at 3:53 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote: > The only time when __len__ can be larger than sys.maxsize is when the > class implements some kind of virtual space where the values are > computed on the fly. In such cases trying to walk over all values is > bound to t

Re: [Python-3000] Should len() clip to sys.maxsize or raiseOverflowError?

2008-09-02 Thread Adam Olsen
On Tue, Sep 2, 2008 at 2:53 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote: > The only time when __len__ can be larger than sys.maxsize is when the > class implements some kind of virtual space where the values are > computed on the fly. In such cases trying to walk over all values is > bound to ta

Re: [Python-3000] Should len() clip to sys.maxsize or raiseOverflowError?

2008-09-02 Thread Nick Coghlan
Guido van Rossum wrote: > The only time when __len__ can be larger than sys.maxsize is when the > class implements some kind of virtual space where the values are > computed on the fly. In such cases trying to walk over all values is > bound to take forever, and the length is likely not of all that

Re: [Python-3000] Should len() clip to sys.maxsize or raiseOverflowError?

2008-09-02 Thread Nick Coghlan
Dj Gilcrease wrote: > why would it raise an index error when log_entries has more indicies > then sys.maxsize, it should just check the entry @ sys.maxsize. > > Maybe I missed it, but why cant len just return an int, which if I > remember correctly is now a long in py3k, so on a 64 bit system len

Re: [Python-3000] Should len() clip to sys.maxsize or raiseOverflowError?

2008-09-02 Thread Raymond Hettinger
From: "Guido van Rossum" <[EMAIL PROTECTED]> That said, I would actually be okay with the status quo (which does raise an OverflowError) as long as we commit to fixing this properly in 2.7 / 3.1, by removing the range restriction (like we've done for other int operations a long time ago). And t

Re: [Python-3000] Should len() clip to sys.maxsize or raiseOverflowError?

2008-09-02 Thread Greg Ewing
Nick Coghlan wrote: - we're just going to have to add a second C level method slot that uses the unaryfunc signature (returning PyObject *) for a "virtual length" method in addition to the existing mp_length and sq_length (which return PySsize_t). As an aside, is there any plan to clean up the