[ python-Bugs-1022912 ] Generator exps fail with large value of range

SourceForge.net noreply at sourceforge.net
Mon Sep 6 09:19:35 CEST 2004


Bugs item #1022912, was opened at 2004-09-06 19:19
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1022912&group_id=5470

Category: Python Interpreter Core
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Andy Elvey (mr_moose)
Assigned to: Nobody/Anonymous (nobody)
Summary: Generator exps fail with large value of range

Initial Comment:
  My platform - Mepis Linux, kernel 2.6.4 , Pentium III 

  I tested generator expressions by using the following
statement (which finds the sum of a range of numbers) - 

  sum(a for a in range(1, 123))

  As can be seen in the output below, this works fine
for small values of a.  However, it gives an
OverflowError for large values of a.  

********* Start of output
*******************************************

  Python 2.4a3 (#1, Sep  5 2004, 15:03:34)
[GCC 3.3.3 (Debian 20040429)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> sum(a for a in range(1, 123))
7503
>>> sum(a for a in range(1, 999999999999999))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OverflowError: range() result has too many items
>>> 

*********** End of output
*********************************************

     




----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1022912&group_id=5470


More information about the Python-bugs-list mailing list