[Python-bugs-list] [ python-Feature Requests-661057 ] xrange concatenation

noreply@sourceforge.net noreply@sourceforge.net
Fri, 03 Jan 2003 03:44:07 -0800


Feature Requests item #661057, was opened at 2003-01-02 12:29
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=661057&group_id=5470

Category: Python Library
Group: None
Status: Closed
Resolution: Rejected
Priority: 5
Submitted By: paul rubin (phr)
Assigned to: Nobody/Anonymous (nobody)
Summary: xrange concatenation

Initial Comment:
xrange is advertised as working like range, but doesn't
support concatenation:

range(5) + range(6, 9) => [0,1,2,3,4,6,7,8,9]

[2] + range(3, 10, 2) => (2, 3, 5, 7, 9]

Doing these things with xrange throws an error.

It would be nice if xrange supported + for
concatenation, so
the above examples would work.  This should be easy to
implement now that there are iterator objects.

Paul


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

>Comment By: paul rubin (phr)
Date: 2003-01-03 11:44

Message:
Logged In: YES 
user_id=72053

The normal behavior of behavior of xrange would not change.
 The xrange object would simply support an __add__ method
just like lists do.  When you add xranges together, you'd
get a new kind of object which would be an iterator with
xranges inside.  When you use an xrange in the normal way,
it wouldn't slow down at all.  It just seems like a needless
and inconvenient inconsistency that xrange can't be used
like range in this situation.

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

Comment By: Guido van Rossum (gvanrossum)
Date: 2003-01-02 15:31

Message:
Logged In: YES 
user_id=6380

I guess the docs need to be updated. xrange() is supposed to
be as light and fast as possible for a single use case: "for
i in xrange(...): ...". Everything else is fluff, and in
fact several features have been deprecated.

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

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