Author: Maciej Fijalkowski <[email protected]>
Branch: numpypy-problems
Changeset: r58143:80f65c2bf92c
Date: 2012-10-16 18:18 +0200
http://bitbucket.org/pypy/pypy/changeset/80f65c2bf92c/
Log: Start fixing casting to stuff
diff --git a/pypy/module/micronumpy/stdobjspace.py
b/pypy/module/micronumpy/stdobjspace.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/micronumpy/stdobjspace.py
@@ -0,0 +1,11 @@
+
+from pypy.objspace.std import stringobject
+from pypy.module.micronumpy import interp_boxes
+
+def delegate_stringbox2stringobj(space, w_box):
+ return space.wrap(w_box.dtype.itemtype.to_str(w_box))
+
+def register_delegates(typeorder):
+ typeorder[interp_boxes.W_StringBox] = [
+ (stringobject.W_StringObject, delegate_stringbox2stringobj),
+ ]
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
@@ -1494,7 +1494,7 @@
# builder.append(arr.storage[i])
# i += 1
#return builder.build()
- def to_str(self, item):
+ def to_str(self, item):
builder = StringBuilder()
assert isinstance(item, interp_boxes.W_StringBox)
i = 0
diff --git a/pypy/objspace/std/model.py b/pypy/objspace/std/model.py
--- a/pypy/objspace/std/model.py
+++ b/pypy/objspace/std/model.py
@@ -182,6 +182,10 @@
(complexobject.W_ComplexObject,
smallintobject.delegate_SmallInt2Complex),
]
+ if config.objspace.usemodules.micronumpy:
+ from pypy.module.micronumpy.stdobjspace import register_delegates
+ register_delegates(self.typeorder)
+
self.typeorder[boolobject.W_BoolObject] += [
(intobject.W_IntObject, boolobject.delegate_Bool2IntObject),
(floatobject.W_FloatObject, floatobject.delegate_Bool2Float),
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit