[pypy-commit] pypy refactor-signature: kill some unused code
fijal
noreply at buildbot.pypy.org
Mon Dec 19 19:44:31 CET 2011
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: refactor-signature
Changeset: r50717:0ed929dcacd0
Date: 2011-12-19 20:43 +0200
http://bitbucket.org/pypy/pypy/changeset/0ed929dcacd0/
Log: kill some unused code
diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -602,40 +602,28 @@
@jit.unroll_safe
def create_slice(self, space, chunks):
- concr = self.get_concrete()
- assert isinstance(concr, ConcreteArray)
- if len(chunks) == 1:
- start, stop, step, lgt = chunks[0]
- if step == 0:
- shape = self.shape[1:]
- strides = concr.strides[1:]
- backstrides = concr.backstrides[1:]
- else:
- shape = [lgt] + self.shape[1:]
- strides = [concr.strides[0] * step] + concr.strides[1:]
- backstrides = [(lgt - 1) * concr.strides[0] * step] + concr.backstrides[1:]
- start *= concr.strides[0]
- start += concr.start
- else:
- shape = []
- strides = []
- backstrides = []
- start = concr.start
- i = -1
- for i, (start_, stop, step, lgt) in enumerate(chunks):
- if step != 0:
- shape.append(lgt)
- strides.append(concr.strides[i] * step)
- backstrides.append(concr.strides[i] * (lgt - 1) * step)
- start += concr.strides[i] * start_
- # add a reminder
- s = i + 1
- assert s >= 0
- shape += concr.shape[s:]
- strides += concr.strides[s:]
- backstrides += concr.backstrides[s:]
+ #if not isinstance(self, ConcreteArray):
+ # return VirtualSlice(self, chunks)
+ self = self.get_concrete()
+ shape = []
+ strides = []
+ backstrides = []
+ start = self.start
+ i = -1
+ for i, (start_, stop, step, lgt) in enumerate(chunks):
+ if step != 0:
+ shape.append(lgt)
+ strides.append(self.strides[i] * step)
+ backstrides.append(self.strides[i] * (lgt - 1) * step)
+ start += self.strides[i] * start_
+ # add a reminder
+ s = i + 1
+ assert s >= 0
+ shape += self.shape[s:]
+ strides += self.strides[s:]
+ backstrides += self.backstrides[s:]
return W_NDimSlice(start, strides[:], backstrides[:],
- shape[:], concr)
+ shape[:], self)
def descr_reshape(self, space, args_w):
"""reshape(...)
@@ -718,6 +706,7 @@
res_shape = res_shape or self.shape
return signature.find_sig(self.create_sig(res_shape), self)
+
def convert_to_array(space, w_obj):
if isinstance(w_obj, BaseArray):
return w_obj
@@ -765,6 +754,7 @@
def get_concrete_or_scalar(self):
return self
+
class VirtualArray(BaseArray):
"""
Class for representing virtual arrays, such as binary ops or ufuncs
@@ -823,6 +813,11 @@
def find_dtype(self):
return self.res_dtype
+class VirtualSlice(VirtualArray):
+ def __init__(self, parent, chunks):
+ self.parent = parent
+ self.chunks = chunks
+ VirtualArray.__init__(self, 'slice', parent.shape, parent.find_dtype())
class Call1(VirtualArray):
def __init__(self, ufunc, name, shape, res_dtype, values):
@@ -934,6 +929,7 @@
return signature.ViewSignature(self.dtype)
return signature.ArraySignature(self.dtype)
+
class ViewArray(ConcreteArray):
def copy(self):
array = W_NDimArray(self.size, self.shape[:], self.find_dtype())
More information about the pypy-commit
mailing list