Author: Maciej Fijalkowski <[email protected]>
Branch: numpy-record-dtypes
Changeset: r52452:575766b2e255
Date: 2012-02-14 16:27 +0200
http://bitbucket.org/pypy/pypy/changeset/575766b2e255/
Log: speedup tests a bti and fix one more
diff --git a/pypy/module/micronumpy/interp_support.py
b/pypy/module/micronumpy/interp_support.py
--- a/pypy/module/micronumpy/interp_support.py
+++ b/pypy/module/micronumpy/interp_support.py
@@ -74,7 +74,7 @@
a = W_NDimArray(count, [count], dtype=dtype)
for i in range(count):
val = dtype.itemtype.runpack_str(s[i*itemsize:i*itemsize + itemsize])
- a.dtype.setitem(a.storage, i, val)
+ a.dtype.setitem(a, i, val)
return space.wrap(a)
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -6,7 +6,7 @@
from pypy.module.micronumpy import interp_boxes
from pypy.objspace.std.floatobject import float2string
from pypy.rlib import rfloat, libffi, clibffi
-from pypy.rlib.objectmodel import specialize
+from pypy.rlib.objectmodel import specialize, we_are_translated
from pypy.rlib.rarithmetic import widen, byteswap
from pypy.rpython.lltypesystem import lltype, rffi
from pypy.rlib.rstruct.runpack import runpack
@@ -115,8 +115,11 @@
raise NotImplementedError
def _read(self, storage, width, i, offset):
- return libffi.array_getitem(clibffi.cast_type_to_ffitype(self.T),
- width, storage, i, offset)
+ if we_are_translated():
+ return libffi.array_getitem(clibffi.cast_type_to_ffitype(self.T),
+ width, storage, i, offset)
+ else:
+ return libffi.array_getitem_T(self.T, width, storage, i, offset)
def read(self, arr, width, i, offset):
return self.box(self._read(arr.storage, width, i, offset))
@@ -125,8 +128,11 @@
return bool(self.for_computation(self._read(arr.storage, width, i,
offset)))
def _write(self, storage, width, i, offset, value):
- libffi.array_setitem(clibffi.cast_type_to_ffitype(self.T),
- width, storage, i, offset, value)
+ if we_are_translated():
+ libffi.array_setitem(clibffi.cast_type_to_ffitype(self.T),
+ width, storage, i, offset, value)
+ else:
+ libffi.array_setitem_T(self.T, width, storage, i, offset, value)
def store(self, arr, width, i, offset, box):
diff --git a/pypy/rlib/libffi.py b/pypy/rlib/libffi.py
--- a/pypy/rlib/libffi.py
+++ b/pypy/rlib/libffi.py
@@ -424,6 +424,11 @@
return rffi.cast(rffi.CArrayPtr(TYPE), addr)[0]
assert False
+def array_getitem_T(TYPE, width, addr, index, offset):
+ addr = rffi.ptradd(addr, index * width)
+ addr = rffi.ptradd(addr, offset)
+ return rffi.cast(rffi.CArrayPtr(TYPE), addr)[0]
+
@specialize.call_location()
@jit.oopspec("libffi_array_setitem(ffitype, width, addr, index, offset,
value)")
def array_setitem(ffitype, width, addr, index, offset, value):
@@ -434,3 +439,8 @@
rffi.cast(rffi.CArrayPtr(TYPE), addr)[0] = value
return
assert False
+
+def array_setitem_T(TYPE, width, addr, index, offset, value):
+ addr = rffi.ptradd(addr, index * width)
+ addr = rffi.ptradd(addr, offset)
+ rffi.cast(rffi.CArrayPtr(TYPE), addr)[0] = value
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit