diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2013-04-02 01:06:21 +0200 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2013-04-11 18:52:03 +0200 |
commit | 1675ad9e5b95605a851337f407e1fad33cf10c9c (patch) | |
tree | aeaa80c79a2a8300341a153dac8d977d5ebfc9f3 /numpy/lib/function_base.py | |
parent | 0350d5e2194494dc1bd8bb10759557e30980fef0 (diff) | |
download | numpy-1675ad9e5b95605a851337f407e1fad33cf10c9c.tar.gz |
FIX: rename xrange to range in python 2
np.delete abuses range to calculate start/stop/step and len. This
would create potentially large intermediates if it was a list, so
for numpy/lib/function_base.py and python < 3, use range = xrange.
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index d67b97b1d..43bd3af8b 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -33,6 +33,9 @@ from ._compiled_base import add_newdoc_ufunc import numpy as np import collections +# Force range to be a generator, for np.delete's usage. +if sys.version_info[0] < 3: + range = xrange def iterable(y): """ @@ -3467,7 +3470,7 @@ def delete(arr, obj, axis=None): if isinstance(obj, slice): start, stop, step = obj.indices(N) - xr = xrange(start, stop, step) + xr = range(start, stop, step) numtodel = len(xr) if numtodel <= 0: |