Title: Expose xrange type in builtins
Type: Stage:
Components: Interpreter Core Versions: Python 2.3
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: gvanrossum, nobody, rhettinger, skip.montanaro
Priority: normal Keywords: patch

Created on 2002-05-23 20:52 by skip.montanaro, last changed 2002-06-05 23:16 by rhettinger. This issue is now closed.

File name Uploaded Description Edit
xrange.diff skip.montanaro, 2002-05-23 20:52
Messages (5)
msg40101 - (view) Author: Skip Montanaro (skip.montanaro) * Date: 2002-05-23 20:52
The attached patch to rangeobject.c and bltinmodule.c exposes the
xrange type in te builtins module instead of a function.  The test suite 
passes.  The one obvious problem I'm aware of is that I simply copied 
get_len_of_range from bltinmodule.c, so it's now duplicated (it's used 
by range_new() as well).  I didn't want to create another _Py_* 
symbol just to share this little bit of code.  I'll be happy to resolve this 
problem however seems best. 

msg40102 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2002-05-24 10:55
Logged In: YES 

Looks good.  Compiles okay on Win32.  Regression tests 
(personal testfarm and python standard) run fine.

Consider changing the line in (even if it is going to 
be deprecated) from, XRangeType = type(xrange(0)), to 

Also, do you want to go all the way with this one and 
make the type subclassable like we did with enumerate()?
msg40103 - (view) Author: Nobody/Anonymous (nobody) Date: 2002-05-24 19:09
Logged In: NO 

The xrange type should be as minimalistic as possible,
so making it subclassable is not high on my list.

--Guido (not logged in)
msg40104 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-06-05 20:20
Logged In: YES 

Raymond, I now approve of this patch. Can you integrate it 
with the rest of your xrange work?
msg40105 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2002-06-05 23:16
Logged In: YES 


Committed as:
rangeobject.c 2.39
bltinmodule.c 2.258 1.28 1.35
Date User Action Args
2002-05-23 20:52:22skip.montanarocreate