Author: Antonio Cuni <[email protected]>
Branch: faster-rstruct
Changeset: r80811:ec447791f752
Date: 2015-11-20 18:34 +0100
http://bitbucket.org/pypy/pypy/changeset/ec447791f752/
Log: translation fix; I didn't find a better way to express
specialize.arg0_and_argtype1
diff --git a/rpython/rlib/rstruct/nativefmttable.py
b/rpython/rlib/rstruct/nativefmttable.py
--- a/rpython/rlib/rstruct/nativefmttable.py
+++ b/rpython/rlib/rstruct/nativefmttable.py
@@ -46,7 +46,7 @@
@specialize.argtype(0)
def unpack_double(fmtiter):
try:
- doubleval = unpack_fastpath(rffi.DOUBLE, fmtiter)
+ doubleval = unpack_fastpath(rffi.DOUBLE)(fmtiter)
except CannotUnpack:
# slow path, take the slice
input = fmtiter.read(sizeof_double)
@@ -71,7 +71,7 @@
@specialize.argtype(0)
def unpack_float(fmtiter):
try:
- floatval = unpack_fastpath(rffi.FLOAT, fmtiter)
+ floatval = unpack_fastpath(rffi.FLOAT)(fmtiter)
except CannotUnpack:
input = fmtiter.read(sizeof_float)
floatval = str_storage_getitem(rffi.FLOAT, input, 0)
diff --git a/rpython/rlib/rstruct/standardfmttable.py
b/rpython/rlib/rstruct/standardfmttable.py
--- a/rpython/rlib/rstruct/standardfmttable.py
+++ b/rpython/rlib/rstruct/standardfmttable.py
@@ -136,14 +136,17 @@
class CannotUnpack(Exception):
pass
[email protected](0)
-def unpack_fastpath(TYPE, fmtiter):
- size = rffi.sizeof(TYPE)
- strbuf, pos = fmtiter.get_buffer_as_string_maybe()
- if strbuf is None or pos % size != 0 or not USE_FASTPATH:
- raise CannotUnpack
- fmtiter.skip(size)
- return str_storage_getitem(TYPE, strbuf, pos)
[email protected]()
+def unpack_fastpath(TYPE):
+ @specialize.argtype(0)
+ def do_unpack_fastpath(fmtiter):
+ size = rffi.sizeof(TYPE)
+ strbuf, pos = fmtiter.get_buffer_as_string_maybe()
+ if strbuf is None or pos % size != 0 or not USE_FASTPATH:
+ raise CannotUnpack
+ fmtiter.skip(size)
+ return str_storage_getitem(TYPE, strbuf, pos)
+ return do_unpack_fastpath
@specialize.argtype(0)
def unpack_pad(fmtiter, count):
@@ -213,7 +216,7 @@
if fmtiter.bigendian != native_is_bigendian:
return False
try:
- intvalue = unpack_fastpath(TYPE, fmtiter)
+ intvalue = unpack_fastpath(TYPE)(fmtiter)
except CannotUnpack:
return False
if not signed and size < native_int_size:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit