[pypy-svn] r33632 - pypy/dist/pypy/module/__builtin__
cfbolz at codespeak.net
cfbolz at codespeak.net
Tue Oct 24 10:28:12 CEST 2006
Author: cfbolz
Date: Tue Oct 24 10:28:11 2006
New Revision: 33632
Modified:
pypy/dist/pypy/module/__builtin__/__init__.py
pypy/dist/pypy/module/__builtin__/functional.py
Log:
less insane way to have two different range implementations
Modified: pypy/dist/pypy/module/__builtin__/__init__.py
==============================================================================
--- pypy/dist/pypy/module/__builtin__/__init__.py (original)
+++ pypy/dist/pypy/module/__builtin__/__init__.py Tue Oct 24 10:28:11 2006
@@ -140,14 +140,6 @@
space.setitem(builtin.w_dict, space.wrap('None'), space.w_None)
return builtin
- def __init__(self, space, *args):
- "NOT_RPYTHON: patches range if option withrangelist is set."
- #XXX slightly strange that the __init__ changes a class attribute...
- if (space.config.objspace.std.withrangelist and
- space.config.objspace.name == "std"):
- self.interpleveldefs["range"] = "functional.range_withrangelist"
- MixedModule.__init__(self, space, *args)
-
def setup_after_space_initialization(self):
"""NOT_RPYTHON"""
space = self.space
Modified: pypy/dist/pypy/module/__builtin__/functional.py
==============================================================================
--- pypy/dist/pypy/module/__builtin__/functional.py (original)
+++ pypy/dist/pypy/module/__builtin__/functional.py Tue Oct 24 10:28:11 2006
@@ -68,6 +68,9 @@
to zero) to stop - 1 by step (defaults to 1). Use a negative step to
get a list in decending order."""
+ if (space.config.objspace.name == "std" and
+ space.config.objspace.std.withrangelist):
+ return range_withrangelist(space, w_x, w_y, w_step)
try:
# save duplication by redirecting every error to applevel
x = space.int_w(w_x)
@@ -93,10 +96,7 @@
range_fallback = applevel(getsource(app_range), getfile(app_range)
).interphook('range')
-def range_withrangelist(space, w_x, w_y=None, w_step=1):
- """Return a list of integers in arithmetic position from start (defaults
-to zero) to stop - 1 by step (defaults to 1). Use a negative step to
-get a list in decending order."""
+def range_withrangelist(space, w_x, w_y, w_step):
# XXX object space dependant
from pypy.objspace.std.rangeobject import W_RangeListObject
try:
@@ -111,5 +111,4 @@
except (OperationError, ValueError, OverflowError):
return range_fallback(space, w_x, w_y, w_step)
return W_RangeListObject(start, step, howmany)
-range_withrangelist.unwrap_spec = [ObjSpace, W_Root, W_Root, W_Root]
More information about the Pypy-commit
mailing list