Author: Antonio Cuni <[email protected]>
Branch: faster-rstruct-2
Changeset: r91183:ed8803b41b6c
Date: 2017-05-04 19:24 +0200
http://bitbucket.org/pypy/pypy/changeset/ed8803b41b6c/
Log: implement and test SubBuffer.typed_read; this fixes
pypy/module/struct/test/test_struct.py:test_unpack_from
diff --git a/rpython/rlib/buffer.py b/rpython/rlib/buffer.py
--- a/rpython/rlib/buffer.py
+++ b/rpython/rlib/buffer.py
@@ -207,3 +207,7 @@
from rpython.rtyper.lltypesystem import rffi
ptr = self.buffer.get_raw_address()
return rffi.ptradd(ptr, self.offset)
+
+ @specialize.ll_and_arg(1)
+ def typed_read(self, TP, byte_offset):
+ return self.buffer.typed_read(TP, byte_offset + self.offset)
diff --git a/rpython/rlib/test/test_buffer.py b/rpython/rlib/test/test_buffer.py
--- a/rpython/rlib/test/test_buffer.py
+++ b/rpython/rlib/test/test_buffer.py
@@ -114,6 +114,14 @@
return buf.typed_read(TYPE, offset)
+class TestSubBufferTypedReadDirect(BaseTypedReadTest):
+
+ def read(self, TYPE, data, offset):
+ buf = StringBuffer('xx' + data)
+ subbuf = SubBuffer(buf, 2, len(data))
+ return subbuf.typed_read(TYPE, offset)
+
+
class TestCompiled(BaseTypedReadTest):
cache = {}
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit