Author: Maciej Fijalkowski <[email protected]>
Branch: numpy-multidim-shards
Changeset: r49407:c857554d0c6c
Date: 2011-11-14 18:37 +0100
http://bitbucket.org/pypy/pypy/changeset/c857554d0c6c/
Log: rpythonize a bit. Disable _immutable_fields_ for now
diff --git a/pypy/module/micronumpy/compile.py
b/pypy/module/micronumpy/compile.py
--- a/pypy/module/micronumpy/compile.py
+++ b/pypy/module/micronumpy/compile.py
@@ -208,11 +208,11 @@
def execute(self, interp):
arr = interp.variables[self.name]
- w_index = self.index.execute(interp).eval(0).wrap(interp.space)
+ w_index =
self.index.execute(interp).eval(arr.start_iter()).wrap(interp.space)
# cast to int
if isinstance(w_index, FloatObject):
w_index = IntObject(int(w_index.floatval))
- w_val = self.expr.execute(interp).eval(0).wrap(interp.space)
+ w_val =
self.expr.execute(interp).eval(arr.start_iter()).wrap(interp.space)
arr.descr_setitem(interp.space, w_index, w_val)
def __repr__(self):
@@ -249,7 +249,7 @@
w_res = w_lhs.descr_sub(interp.space, w_rhs)
elif self.name == '->':
if isinstance(w_rhs, Scalar):
- w_rhs = w_rhs.eval(0).wrap(interp.space)
+ w_rhs = w_rhs.eval(w_rhs.start_iter()).wrap(interp.space)
assert isinstance(w_rhs, FloatObject)
w_rhs = IntObject(int(w_rhs.floatval))
w_res = w_lhs.descr_getitem(interp.space, w_rhs)
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
@@ -9,7 +9,8 @@
from pypy.rlib.rstring import StringBuilder
numpy_driver = jit.JitDriver(greens = ['signature'],
- reds = ['result_size', 'i', 'self', 'result'])
+ reds = ['result_size', 'i', 'ri', 'self',
+ 'result'])
all_driver = jit.JitDriver(greens=['signature'], reds=['i', 'self', 'dtype'])
any_driver = jit.JitDriver(greens=['signature'], reds=['i', 'self', 'dtype'])
slice_driver = jit.JitDriver(greens=['signature'], reds=['self', 'source',
@@ -162,7 +163,7 @@
_attrs_ = ["invalidates", "signature", "shape", "shards", "backshards",
"start"]
- _immutable_fields_ = ['shape[*]', "shards[*]", "backshards[*]", 'start']
+ #_immutable_fields_ = ['shape[*]', "shards[*]", "backshards[*]", 'start']
shards = None
start = 0
@@ -521,9 +522,11 @@
backshards.append(self.shards[i] * lgt * step)
start += self.shards[i] * start_
# add a reminder
- shape += self.shape[i + 1:]
- shards += self.shards[i + 1:]
- backshards += self.backshards[i + 1:]
+ s = i + 1
+ assert s >= 0
+ shape += self.shape[s:]
+ shards += self.shards[s:]
+ backshards += self.backshards[s:]
return NDimSlice(self, new_sig, start, shards, backshards, shape)
def descr_mean(self, space):
@@ -627,7 +630,7 @@
ri = result.start_iter()
while not ri.done():
numpy_driver.jit_merge_point(signature=signature,
- result_size=result_size, i=i,
+ result_size=result_size, i=i, ri=ri,
self=self, result=result)
result.dtype.setitem(result.storage, ri.offset, self.eval(i))
i.next()
@@ -770,7 +773,7 @@
class NDimSlice(ViewArray):
signature = signature.BaseSignature()
- _immutable_fields_ = ['shape[*]', 'shards[*]', 'backshards[*]', 'start']
+ #_immutable_fields_ = ['shape[*]', 'shards[*]', 'backshards[*]', 'start']
def __init__(self, parent, signature, start, shards, backshards,
shape):
diff --git a/pypy/module/micronumpy/test/test_zjit.py
b/pypy/module/micronumpy/test/test_zjit.py
--- a/pypy/module/micronumpy/test/test_zjit.py
+++ b/pypy/module/micronumpy/test/test_zjit.py
@@ -47,7 +47,7 @@
interp = InterpreterState(codes[i])
interp.run(space)
res = interp.results[-1]
- w_res = res.eval(0).wrap(interp.space)
+ w_res = res.eval(res.start_iter()).wrap(interp.space)
if isinstance(w_res, BoolObject):
return float(w_res.boolval)
elif isinstance(w_res, FloatObject):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit